diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index a436d0972bb6ca5afff2a3c944c841295bf99e3b..81e159faffa5ae3085023027eaf0056fef28da39 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -45,56 +45,37 @@ const uint32_t MAX_LOAD_VAVLUE = 3; enum { DM_OK = 0, - DM_FAILED = 1000, - DM_TIME_OUT, - DM_NOT_INIT, - DM_INT_MULTIPLE, - DM_INIT_FAILED, - DM_UNINIT_FAILED, - DM_POINT_NULL, - DM_INPUT_PARA_EMPTY, - DM_NO_PERMISSION, - DM_INVALID_VALUE, - DM_FLATTEN_OBJECT, - DM_MALLOC_ERROR, - DM_COPY_FAILED, - DM_WRITE_FAILED, - DM_DISCOVERY_FAILED, - DM_MAKE_SHARED_FAIL, - DM_SERVICE_NOT_READY, - DM_DEVICE_ALREADY_TRUSTED, - ERR_DM_KEY_ALREADY_EXISTS, - ERR_DM_INPUT_PARA_INVALID, - ERR_DM_SUBSCRIBE_DP_EVENTS, - ERR_DM_UNSUBSCRIBE_DP_EVENTS, - ERR_DM_LOAD_FWK_SA_FAIL, - DM_IPC_FAILED = 2000, - DM_IPC_TRANSACTION_FAILED, - DM_IPC_FLATTEN_OBJECT, - DM_IPC_COPY_FAILED, - DM_IPC_SEND_REQUEST_FAILED, - DM_IPC_NOT_REGISTER_FUNC, - DM_IPC_RESPOND_ERROR, - DM_IPC_WRITE_TOKEN_ERROR, - DM_DISCOVERY_REPEATED, - DM_AUTH_NOT_SUPPORT, - DM_AUTH_BUSINESS_BUSY, - DM_AUTH_INPUT_FAILED, - DM_AUTH_STATE_FAILED, - DM_AUTH_DEVICE_AUTHED, - DM_AUTH_OPEN_SESSION_FAILED, - DM_AUTH_PEER_REJECT, - DM_AUTH_NOT_AUTH, - DM_AUTH_DONT_AUTH, - DM_AUTH_NOT_START, - DM_MESSAGE_NOT_COMPLETE, - DM_SOFTBUS_FAILED = 3000, - DM_SOFTBUS_CREATE_SESSION_SERVER_FAILED, - DM_HICHAIN_FAILED = 4000, - DM_HICHAIN_GROUP_CREATE_FAILED, - DM_HICHAIN_MEMBER_ADD_FAILED, - DM_HICHAIN_CREATE_CHANNEL_FAILED, - DM_AUTH_NO_TIMER, + ERR_DM_FAILED = -20000, + ERR_DM_TIME_OUT = -20001, + ERR_DM_NOT_INIT = -20002, + ERR_DM_INIT_REPEATED = -20003, + ERR_DM_INIT_FAILED = -20004, + ERR_DM_UNINIT_FAILED = -20005, + ERR_DM_POINT_NULL = -20006, + ERR_DM_INPUT_PARAMETER_EMPTY = -20007, + ERR_DM_NO_PERMISSION = -20008, + ERR_DM_MALLOC_FAILED = -20009, + ERR_DM_STRCOPY_FAILED = -20010, + ERR_DM_WRITE_FAILED = -20011, + ERR_DM_DISCOVERY = -20012, + ERR_DM_KEY_ALREADY_EXISTS = -20013, + ERR_DM_UNSUBSCRIBE_DP_EVENTS = -20014, + ERR_DM_IPC = -20015, + ERR_DM_IPC_WRITE = -20016, + ERR_DM_IPC_COPY = -20017, + ERR_DM_IPC_SEND_REQUEST = -20018, + ERR_DM_IPC_REGISTER_FUNC = -20019, + ERR_DM_IPC_RESPOND = -20020, + ERR_DM_IPC_WRITE_TOKEN = -20021, + ERR_DM_DISCOVERY_REPEATED = -20022, + ERR_DM_AUTH_BUSINESS_BUSY = -20023, + ERR_DM_AUTH_INPUT_PARAMETER_EMPTY = -20024, + ERR_DM_AUTH_OPEN_SESSION = -20025, + ERR_DM_OPPOSITE_REFUSED_REJECT = -20026, + ERR_DM_REFUSED_REJECT = -20027, + ERR_DM_AUTH_DONT_AUTH = -20028, + ERR_DM_AUTH_NOT_START = -20029, + ERR_DM_HICHAIN_CREATE_GROUP = -20030, }; const std::string TARGET_PKG_NAME_KEY = "targetPkgName"; const std::string HOST_PKG_NAME_KEY = "hostPackageName"; @@ -213,12 +194,55 @@ const std::string WAIT_REQUEST_TIMEOUT_TASK = TIMER_PREFIX + "waitRequest"; const std::string STATE_TIMER_PREFIX = "stateTimer_"; const int32_t TIMER_PREFIX_LENGTH = 19; const int32_t TIMER_DEFAULT = 0; -const int32_t NO_TIMER = -1; -const int32_t INIT_SIZE = 3; -const int32_t MAX_EVENT_NUMBER = 10; -const int32_t EXPAND_TWICE = 2; -const int32_t SEC_TO_MM = 1000; -const int32_t MAX_EVENTS = 5; + +//error code info +const std::string DM_OK_INFO = "DeviceManager APIs called successfully."; +const std::string DM_FAILED_INFO = "DeviceManager APIs called failed. Please try again later."; +const std::string DM_TIME_OUT_INFO = + "DeviceManager internal process execution timed out. Please try again later."; +const std::string DM_NOT_INIT_INFO = + "DeviceManager service has not been initialized. Restart the device and try again."; +const std::string DM_INIT_REPEATED_INFO = "DeviceManager service does not allowed repeated initialization."; +const std::string DM_INIT_FAILED_INFO = + "DeviceManager service fails to be initialized. Restart the device and try again."; +const std::string DM_UNINIT_FAILED_INFO = "DeviceManager failed to deinitialize. Restart the device and try again."; +const std::string DM_POINT_NULL_INFO = + "DeviceManager internal process occurs NullPointerException. Please try again later."; +const std::string DM_INPUT_PARAMETER_EMPTY_INFO = "The API input parameter is invalid. Please confirm and try again."; +const std::string DM_NO_PERMISSION_INFO = + "The hap application has no permission to call DeviceManager APIs. Please confirm and try again."; +const std::string DM_MALLOC_FAILED_INFO = + "Device resources are insufficient. Memory allocation failed. Restart the device and try again."; +const std::string DM_STRCOPY_FAILED_INFO = + "Device resources are insufficient. Memory copy failed. Restart the device and try again."; +const std::string DM_WRITE_FAILED_INFO = "IPC process abnormal. Write object failed. Restart the device and try again."; +const std::string DM_DISCOVERY_INFO = "Failed to discover devices. Please try again later."; +const std::string DM_KEY_ALREADY_EXISTS_INFO = "DeviceManager service abnormal. Restart the device and try again."; +const std::string DM_UNSUBSCRIBE_DP_EVENTS_INFO = + "Failed to call SubscribeProfileEvents API of DP module. Please try again later."; +const std::string DM_IPC_ERR_INFO = "IPC process abnormal. Restart the device and try again."; +const std::string DM_IPC_WRITE_INFO = "IPC process failed to write data. Restart the device and try again."; +const std::string DM_IPC_COPY_INFO = "IPC process failed to copy data. Restart the device and try again."; +const std::string DM_IPC_SEND_REQUEST_INFO = "IPC process failed to send request. Restart the device and try again."; +const std::string DM_IPC_REGISTER_FUNC_INFO = + "IPC process failed to register function. Restart the device and try again."; +const std::string DM_IPC_RESPOND_INFO = "IPC process failed to receive response. Restart the device and try again."; +const std::string DM_IPC_WRITE_TOKEN_INFO = "IPC process failed to write token. Restart the device and try again."; +const std::string DM_DISCOVERY_REPEATED_INFO = + "Repeat device discovery is not allowed within 1 minute. Please try again later."; +const std::string DM_AUTH_BUSINESS_BUSY_INFO = + "The device authentication request is being processed. Please try again later."; +const std::string DM_AUTH_INPUT_PARAMETER_EMPTY_INFO = + "The AuthenticateDevice API input parameter is invalid. Please confirm and try again."; +const std::string DM_AUTH_OPEN_SESSION_INFO = + "Failed to open authenticate session. Please restart the device and try again."; +const std::string DM_OPPOSITE_REFUSED_REJECT_INFO = + "The remote device rejected the request. Please confirm and try again."; +const std::string DM_REFUSED_REJECT_INFO = "The local device rejected the request. Please confirm and try again."; +const std::string DM_AUTH_DONT_AUTH_INFO = "The local device authentication failed. Please try again later."; +const std::string DM_AUTH_NOT_START_INFO = "The device authentication process has not started. Please try again later."; +const std::string DM_HICHAIN_CREATE_GROUP_INFO = + "HiChain module failed to create user group. Please restart the device and try again."; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_CONSTANTS_H diff --git a/ext/pin_auth/src/lite/pin_auth_ui.cpp b/ext/pin_auth/src/lite/pin_auth_ui.cpp index f12a74e46e362658cc0aedc1053d0e8f3e8ec8d6..205d32762cd7d63a0ec16e463657fd81a68dc671 100644 --- a/ext/pin_auth/src/lite/pin_auth_ui.cpp +++ b/ext/pin_auth/src/lite/pin_auth_ui.cpp @@ -39,7 +39,7 @@ int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr a std::shared_ptr dmAbilityManager_ = std::make_shared(); if (dmAbilityManager_ == nullptr) { LOGE("PinAuthUi::dmAbilityManager is null"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("InputPinDialog end"); return StartFaUiService(dmAbilityManager_); @@ -50,7 +50,7 @@ int32_t ClosePage(const int32_t &pageId, std::shared_ptr authMana LOGI("ClosePage hap start"); if (authManager == nullptr) { LOGE("PinAuthUi::authManager is null"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("ClosePage hap end"); authManager->CancelDisplay(); @@ -62,7 +62,7 @@ int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityM AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { LOGE("PinAuthUi::StartFaUiService timeout"); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index da2d8865349b2919c3f42f53e57759bb30e202e1..34a2182ad27f1a7f3b725841070be709dd48fca2 100644 --- a/ext/pin_auth/src/pin_auth.cpp +++ b/ext/pin_auth/src/pin_auth.cpp @@ -40,11 +40,11 @@ int32_t PinAuth::ShowAuthInfo(std::string &authToken, std::shared_ptrShowPinDialog(jsonObject[PIN_CODE_KEY], authManager); } @@ -54,11 +54,11 @@ int32_t PinAuth::StartAuth(std::string &authToken, std::shared_ptrInputPinDialog(jsonObject[PIN_CODE_KEY], authManager); } @@ -71,22 +71,22 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string return DM_OK; } LOGE("Peer rejection"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json authParamJson = nlohmann::json::parse(authParam, nullptr, false); if (authParamJson.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json authTokenJson = nlohmann::json::parse(authToken, nullptr, false); if (authTokenJson.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } if (!authParamJson.contains(PIN_CODE_KEY) || !authParamJson.contains(PIN_TOKEN) || !authTokenJson.contains(PIN_CODE_KEY) || !authTokenJson.contains(PIN_TOKEN)) { LOGE("err json string, first time"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t code = authTokenJson[PIN_CODE_KEY]; std::string pinToken = authTokenJson[PIN_TOKEN]; @@ -95,9 +95,9 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string if (code == inputPinCode && pinToken == inputPinToken) { return DM_OK; } else if (code != inputPinCode && times_ < MAX_VERIFY_TIMES) { - return DM_AUTH_INPUT_FAILED; + return ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; } else { - return DM_FAILED; + return ERR_DM_FAILED; } } diff --git a/ext/pin_auth/src/standard/pin_auth_ui.cpp b/ext/pin_auth/src/standard/pin_auth_ui.cpp index 65851bcb930aea9bdaeac8b714a6876624e5fbbb..6e349747a3a763b568e6c41aa26daa0edd979185 100644 --- a/ext/pin_auth/src/standard/pin_auth_ui.cpp +++ b/ext/pin_auth/src/standard/pin_auth_ui.cpp @@ -33,7 +33,7 @@ int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr au LOGI("ShowPinDialog start"); if (authManager == nullptr) { LOGE("ShowPinDialog authManager is null"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json jsonObj; jsonObj[PIN_CODE_KEY] = code; @@ -63,7 +63,7 @@ int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr a LOGI("InputPinDialog start"); if (authManager == nullptr) { LOGE("ShowPinDialog InputPinDialog is null"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json jsonObj; jsonObj[PIN_CODE_KEY] = code; @@ -102,7 +102,7 @@ int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityM AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { LOGE("PinAuthUi::StartFaService timeout"); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } diff --git a/ext/profile/src/device_profile_adapter.cpp b/ext/profile/src/device_profile_adapter.cpp index b4f6425ac258a313e896cd4970b79a046f1707df..98180cd608e658b97658587c520cffed4bf938d3 100755 --- a/ext/profile/src/device_profile_adapter.cpp +++ b/ext/profile/src/device_profile_adapter.cpp @@ -36,7 +36,7 @@ int32_t DeviceProfileAdapter::RegisterProfileListener(const std::string &pkgName { if (pkgName.empty() || deviceId.empty() || callback == nullptr) { LOGE("Not a reasonable function argument"); - return ERR_DM_INPUT_PARA_INVALID; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("register profile listener with pkgName: %s", pkgName.c_str()); std::lock_guard mutexLock(deviceProfileAdapterMutex_); @@ -54,7 +54,7 @@ int32_t DeviceProfileAdapter::UnRegisterProfileListener(const std::string &pkgNa { if (pkgName.empty()) { LOGE("not a reasonable function argument"); - return ERR_DM_INPUT_PARA_INVALID; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("unregister profile listener with pkgName: %s", pkgName.c_str()); std::lock_guard mutexLock(deviceProfileAdapterMutex_); diff --git a/ext/profile/src/profile_connector.cpp b/ext/profile/src/profile_connector.cpp index 0b28bfe41bb21c2e292e891e727701a64ee38c11..c24c361ea171c024148c1b6b16836fdee3a99dfe 100755 --- a/ext/profile/src/profile_connector.cpp +++ b/ext/profile/src/profile_connector.cpp @@ -37,7 +37,7 @@ int32_t ProfileConnector::RegisterProfileCallback(const std::string &pkgName, co { if (pkgName.empty() || deviceId.empty() || callback == nullptr) { LOGE("Not a reasonable function argument"); - return ERR_DM_INPUT_PARA_INVALID; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("register profile callback with pkgName: %s", pkgName.c_str()); @@ -62,7 +62,7 @@ int32_t ProfileConnector::UnRegisterProfileCallback(const std::string &pkgName) { if (pkgName.empty()) { LOGE("Not a reasonable function argument"); - return ERR_DM_INPUT_PARA_INVALID; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("unregister profile callback with pkgName: %s", pkgName.c_str()); diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index cad4dad54731737260c03aee3c753e55d8a7b6fa..90936db14eb39a2a97664e478c73347cd9b28d0c 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -48,26 +48,26 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh LOGI("DeviceManager::InitDeviceManager start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || dmInitCallback == nullptr) { LOGE("InitDeviceManager error: Invalid parameter"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } int32_t ret = DM_OK; int32_t retryNum = 0; while (retryNum < SERVICE_INIT_TRY_MAX_NUM) { ret = ipcClientProxy_->Init(pkgName); - if (ret != DM_NOT_INIT) { + if (ret != ERR_DM_NOT_INIT) { break; } usleep(SLEEP_TIME_MS); retryNum++; if (retryNum == SERVICE_INIT_TRY_MAX_NUM) { LOGE("InitDeviceManager error: wait for device manager service starting timeout."); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } } if (ret != DM_OK) { LOGE("InitDeviceManager error: proxy init failed ret: %d", ret); - return DM_INIT_FAILED; + return ERR_DM_INIT_FAILED; } DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); @@ -80,13 +80,13 @@ int32_t DeviceManagerImpl::UnInitDeviceManager(const std::string &pkgName) LOGI("DeviceManager::UnInitDeviceManager start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnInitDeviceManager error: Invalid parameter"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } int32_t ret = ipcClientProxy_->UnInit(pkgName); if (ret != DM_OK) { LOGE("UnInitDeviceManager error: proxy unInit failed ret: %d", ret); - return DM_UNINIT_FAILED; + return ERR_DM_UNINIT_FAILED; } DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(pkgName); @@ -100,7 +100,7 @@ int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, cons LOGI("DeviceManager::GetTrustedDeviceList start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("GetTrustedDeviceList error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -110,13 +110,13 @@ int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(GET_TRUST_DEVICE_LIST, req, rsp); if (ret != DM_OK) { LOGE("GetTrustedDeviceList error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetTrustedDeviceList error: failed ret: %d", ret); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } deviceList = rsp->GetDeviceVec(); @@ -133,13 +133,13 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi int32_t ret = ipcClientProxy_->SendRequest(GET_LOCAL_DEVICE_INFO, req, rsp); if (ret != DM_OK) { LOGE("GetLocalDeviceInfo error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGI("GetLocalDeviceInfo error: failed ret: %d", ret); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } info = rsp->GetLocalDeviceInfo(); @@ -153,7 +153,7 @@ int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, LOGI("DeviceManager::RegisterDevStateCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("RegisterDevStateCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); @@ -169,7 +169,7 @@ int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName LOGI("DeviceManager::UnRegisterDevStateCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnRegisterDevStateCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName); @@ -185,7 +185,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons LOGI("DeviceManager::StartDeviceDiscovery start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("StartDeviceDiscovery error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("DeviceManager StartDeviceDiscovery in, pkgName %s", pkgName.c_str()); @@ -199,7 +199,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(START_DEVICE_DISCOVER, req, rsp); if (ret != DM_OK) { LOGE("StartDeviceDiscovery error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); @@ -217,7 +217,7 @@ int32_t DeviceManagerImpl::StopDeviceDiscovery(const std::string &pkgName, uint1 LOGI("DeviceManager::StopDeviceDiscovery start , pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("StopDeviceDiscovery error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("StopDeviceDiscovery in, pkgName %s", pkgName.c_str()); @@ -228,7 +228,7 @@ int32_t DeviceManagerImpl::StopDeviceDiscovery(const std::string &pkgName, uint1 int32_t ret = ipcClientProxy_->SendRequest(STOP_DEVICE_DISCOVER, req, rsp); if (ret != DM_OK) { LOGE("StopDeviceDiscovery error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); @@ -249,7 +249,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ LOGI("DeviceManager::AuthenticateDevice start , pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("AuthenticateDevice error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::string strDeviceId = deviceInfo.deviceId; @@ -263,13 +263,13 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Failed with ret %d", ret); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } LOGI("DeviceManager::AuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; @@ -281,9 +281,15 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons deviceInfo.deviceId); if (pkgName.empty() || (deviceInfo.deviceId[0] == '\0')) { LOGE("UnAuthenticateDevice error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } + DmDeviceInfo deviceInfo; + int32_t ret = strcpy_s(deviceInfo.deviceId, DM_MAX_DEVICE_ID_LEN, deviceId.c_str()); + if (ret != DM_OK) { + LOGE("UnAuthenticateDevice error: copy deviceId failed"); + return ERR_DM_INPUT_PARAMETER_EMPTY; + } std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); @@ -291,12 +297,12 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(UNAUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Failed with ret %d", ret); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str()); @@ -309,7 +315,7 @@ int32_t DeviceManagerImpl::RegisterDeviceManagerFaCallback(const std::string &pk LOGI("DeviceManager::RegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("RegisterDeviceManagerFaCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, callback); LOGI("DeviceManager::RegisterDevStateCallback completed, pkgName: %s", pkgName.c_str()); @@ -321,7 +327,7 @@ int32_t DeviceManagerImpl::UnRegisterDeviceManagerFaCallback(const std::string & LOGI("DeviceManager::UnRegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnRegisterDeviceManagerFaCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(pkgName); LOGI("DeviceManager::UnRegisterDevStateCallback completed, pkgName: %s", pkgName.c_str()); @@ -334,7 +340,7 @@ int32_t DeviceManagerImpl::VerifyAuthentication(const std::string &pkgName, cons LOGI("DeviceManager::VerifyAuthentication start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("VerifyAuthentication error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterVerifyAuthenticationCallback(pkgName, authPara, callback); @@ -347,7 +353,7 @@ int32_t DeviceManagerImpl::VerifyAuthentication(const std::string &pkgName, cons int32_t ret = ipcClientProxy_->SendRequest(VERIFY_AUTHENTICATION, req, rsp); if (ret != DM_OK) { LOGE("VerifyAuthentication error: Send Request failed ret: %d", ret); - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -364,7 +370,7 @@ int32_t DeviceManagerImpl::GetFaParam(const std::string &pkgName, DmAuthParam &d LOGI("DeviceManager::GetFaParam start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -373,7 +379,7 @@ int32_t DeviceManagerImpl::GetFaParam(const std::string &pkgName, DmAuthParam &d if (ipcClientProxy_->SendRequest(SERVER_GET_DMFA_INFO, req, rsp) != DM_OK) { LOGI("DeviceManagerImpl::GetFaParam start 2"); - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } dmFaParam = rsp->GetDmAuthParam(); LOGI("GetFaParam completed, pkgName: %s", pkgName.c_str()); @@ -385,7 +391,7 @@ int32_t DeviceManagerImpl::SetUserOperation(const std::string &pkgName, int32_t LOGI("DeviceManager::SetUserOperation start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -394,7 +400,7 @@ int32_t DeviceManagerImpl::SetUserOperation(const std::string &pkgName, int32_t req->SetOperation(action); if (ipcClientProxy_->SendRequest(SERVER_USER_AUTH_OPERATION, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -410,7 +416,7 @@ int32_t DeviceManagerImpl::GetUdidByNetworkId(const std::string &pkgName, const { if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -419,7 +425,7 @@ int32_t DeviceManagerImpl::GetUdidByNetworkId(const std::string &pkgName, const req->SetNetWorkId(netWorkId); if (ipcClientProxy_->SendRequest(GET_UDID_BY_NETWORK, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -435,7 +441,7 @@ int32_t DeviceManagerImpl::GetUuidByNetworkId(const std::string &pkgName, const { if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -444,7 +450,7 @@ int32_t DeviceManagerImpl::GetUuidByNetworkId(const std::string &pkgName, const req->SetNetWorkId(netWorkId); if (ipcClientProxy_->SendRequest(GET_UUID_BY_NETWORK, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -459,7 +465,7 @@ int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, { if (pkgName.empty()) { LOGE("RegisterDevStateCallback failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -468,7 +474,7 @@ int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, req->SetExtra(extra); if (ipcClientProxy_->SendRequest(REGISTER_DEV_STATE_CALLBACK, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { @@ -482,7 +488,7 @@ int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName { if (pkgName.empty()) { LOGE("UnRegisterDevStateCallback failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -491,7 +497,7 @@ int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName req->SetExtra(extra); if (ipcClientProxy_->SendRequest(UNREGISTER_DEV_STATE_CALLBACK, req, rsp) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } int32_t ret = rsp->GetErrCode(); if (ret != DM_OK) { diff --git a/interfaces/inner_kits/native_cpp/src/ipc/ipc_client_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/ipc_client_proxy.cpp index 3dc488a681f6a3180056a0d5839b7d9b6069d26c..4e82edf7629b91831439d17d49f54bbe774c1632 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/ipc_client_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/ipc_client_proxy.cpp @@ -23,7 +23,7 @@ namespace DistributedHardware { int32_t IpcClientProxy::Init(const std::string &pkgName) { if (ipcClientManager_ == nullptr) { - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return ipcClientManager_->Init(pkgName); } @@ -31,7 +31,7 @@ int32_t IpcClientProxy::Init(const std::string &pkgName) int32_t IpcClientProxy::UnInit(const std::string &pkgName) { if (ipcClientManager_ == nullptr) { - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return ipcClientManager_->UnInit(pkgName); } @@ -40,7 +40,7 @@ int32_t IpcClientProxy::SendRequest(int32_t cmdCode, std::shared_ptr req { if (req == nullptr || rsp == nullptr || ipcClientManager_ == nullptr) { LOGE("req,rsp or ipc client is null"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return ipcClientManager_->SendRequest(cmdCode, req, rsp); } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp index 3b89b67f4a932624e55f3f08e13482341abec554..4834f1a8b3e15b7a33d3ffc2b36d1c22931f2d8c 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp @@ -30,11 +30,11 @@ int32_t IpcClientManager::Init(const std::string &pkgName) } if (serverProxy_.Init() != DM_OK) { LOGE("server proxy init failed."); - return DM_INIT_FAILED; + return ERR_DM_INIT_FAILED; } if (IpcClientStub::GetInstance().Init() != DM_OK) { LOGE("ipcclientstub init failed."); - return DM_INIT_FAILED; + return ERR_DM_INIT_FAILED; } std::shared_ptr req = std::make_shared(); @@ -59,13 +59,13 @@ int32_t IpcClientManager::UnInit(const std::string &pkgName) { LOGI("UnInitDeviceManager in, pkgName %s", pkgName.c_str()); if (!IsInit(pkgName)) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); if (req == nullptr) { LOGE("req is null"); - return DM_FAILED; + return ERR_DM_FAILED; } req->SetPkgName(pkgName); int32_t ret = serverProxy_.SendCmd(UNREGISTER_DEVICE_MANAGER_LISTENER, req, rsp); @@ -82,7 +82,7 @@ int32_t IpcClientManager::SendRequest(int32_t cmdCode, std::shared_ptr r { std::string pkgName = req->GetPkgName(); if (!IsInit(pkgName)) { - return DM_SERVICE_NOT_READY; + return ERR_DM_NOT_INIT; } return serverProxy_.SendCmd(cmdCode, req, rsp); } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp index 191c579864908ba57b5fc8a498caa55cae89b9f4..2c5fa9e28c200a288d53da2e6827604ac586d0b6 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp @@ -82,7 +82,7 @@ int IpcClientServerProxy::RegisterServerDeathCb(void) g_deathCbId = INVALID_CB_ID; if (RegisterDeathCallback(nullptr, g_svcIdentity, DmDeathCallback, nullptr, &g_deathCbId) != EC_SUCCESS) { LOGE("reg death callback failed"); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } @@ -94,7 +94,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r IpcIo request; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, request, data, MAX_DM_IPC_LEN) != DM_OK) { - return DM_FAILED; + return ERR_DM_FAILED; } { std::lock_guard autoLock(lock_); @@ -102,7 +102,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r if (serviceProxy_ != nullptr && serviceProxy_->Invoke(serviceProxy_, cmdCode, &request, &cmdCode, SendCmdResultCb) != 0) { LOGE("serviceProxy_ invoke failed."); - return DM_FAILED; + return ERR_DM_FAILED; } } LOGI("IpcClientServerProxy::SendCmd:%d, end", cmdCode); @@ -119,11 +119,11 @@ int32_t IpcClientServerProxy::Init(void) serviceProxy_ = GetServerProxy(); if (serviceProxy_ == nullptr) { LOGE("get ipc client proxy failed"); - return DM_FAILED; + return ERR_DM_FAILED; } if (RegisterServerDeathCb() != DM_OK) { LOGE("register server death cb failed"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("ServerProxyInit ok"); return DM_OK; diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp index d692823eaf1121d998c3e5899cd457135f9675b9..58e22c84cff04f321415e2a9b7ccc738546faa38 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_stub.cpp @@ -30,7 +30,7 @@ static int32_t ClientIpcInterfaceMsgHandle(const IpcContext *ctx, void *ipcMsg, (void)arg; if (ipcMsg == nullptr || io == nullptr) { LOGE("invalid param"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } uint32_t code = 0; @@ -49,7 +49,7 @@ int32_t IpcClientStub::Init() } if (RegisterIpcCallback(ClientIpcInterfaceMsgHandle, 0, IPC_WAIT_FOREVER, &clientIdentity_, nullptr) != 0) { LOGE("register ipc cb failed"); - return DM_FAILED; + return ERR_DM_FAILED; } bInit = true; return DM_OK; diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index 35643d54c6bf415b8b3df547b13d5e28b4087ca4..cc6d885c39da6764366f4c00418fd9b090d4ae22 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -50,7 +50,7 @@ ON_IPC_READ_RESPONSE(REGISTER_DEVICE_MANAGER_LISTENER, IpcIo &reply, std::shared { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(IpcIoPopInt32(&reply)); return DM_OK; @@ -96,8 +96,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, IpcIo &reply, std::shared_ptrSetErrCode(DM_IPC_TRANSACTION_FAILED); - return DM_IPC_TRANSACTION_FAILED; + pRsp->SetErrCode(ERR_DM_IPC); + return ERR_DM_IPC; } for (int32_t i = 0; i < deviceNum; ++i) { deviceInfoVec.emplace_back(*pDmDeviceinfo); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp index d7b674e4d0dc875dae2b1b423fd84511c9cd166c..383c4b57c78c15ad260db8b7d7b9c08c430c3ca6 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp @@ -46,13 +46,13 @@ int32_t IpcClientManager::ClientInit() auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (samgr == nullptr) { LOGE("Get SystemAbilityManager Failed"); - return DM_SERVICE_NOT_READY; + return ERR_DM_NOT_INIT; } auto object = samgr->CheckSystemAbility(DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID); if (object == nullptr) { LOGE("Get DeviceManager SystemAbility Failed"); - return DM_SERVICE_NOT_READY; + return ERR_DM_NOT_INIT; } if (dmRecipient_ == nullptr) { @@ -103,7 +103,7 @@ int32_t IpcClientManager::UnInit(const std::string &pkgName) LOGI("in, pkgName %s", pkgName.c_str()); if (dmInterface_ == nullptr) { LOGE("DeviceManager not Init"); - return DM_SERVICE_NOT_READY; + return ERR_DM_NOT_INIT; } std::lock_guard autoLock(lock_); @@ -131,8 +131,8 @@ int32_t IpcClientManager::SendRequest(int32_t cmdCode, std::shared_ptr r LOGI("IpcClientManager::SendRequest in"); std::string pkgName = req->GetPkgName(); if (!IsInit(pkgName)) { - LOGE("IpcClientManager::SendRequest DM_SERVICE_NOT_READY"); - return DM_SERVICE_NOT_READY; + LOGE("IpcClientManager::SendRequest ERR_DM_NOT_INIT"); + return ERR_DM_NOT_INIT; } LOGI("IpcClientManager::SendRequest cmdCode: %d", cmdCode); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp index 6093b9e048060f93b2e99c6baf6c5906c7b029eb..530ac049d1f2916a998d1d8b6bbc047c753b9336 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_server_proxy.cpp @@ -27,7 +27,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r sptr remote = Remote(); if (remote == nullptr) { LOGE("remote service null"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } MessageParcel data; @@ -35,14 +35,14 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { LOGE("WriteInterfaceToken fail!"); - return DM_IPC_WRITE_TOKEN_ERROR; + return ERR_DM_IPC_WRITE_TOKEN; } if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } if (remote->SendRequest((uint32_t)cmdCode, data, reply, option) != DM_OK) { LOGE("SendRequest fail, cmd:%d", cmdCode); - return DM_IPC_SEND_REQUEST_FAILED; + return ERR_DM_IPC_SEND_REQUEST; } return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp index da1049da2712cf6ac11eae598b71549808a91fc5..6d8d5599e8304ab1380a380d92297a77abc404a1 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp @@ -48,7 +48,7 @@ int32_t IpcClientStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std MessageOption option; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { LOGE("set request cmd failed"); - return DM_IPC_FAILED; + return ERR_DM_IPC; } LOGI("cmdCode = %d, flags= %d.", cmdCode, option.GetFlags()); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index 3cb76e3620fdfacefb9191be4c398989e891fe33..32796b7ab69f6c333de0a144aa247eb9532fccf0 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -46,11 +46,11 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa sptr listener = pReq->GetListener(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteRemoteObject(listener)) { LOGE("write listener failed"); - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } return DM_OK; } @@ -59,7 +59,7 @@ ON_IPC_READ_RESPONSE(REGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &reply, std { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -70,7 +70,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr p std::string pkgName = pBaseReq->GetPkgName(); if (!data.WriteString(pkgName)) { LOGE("write papam failed"); - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } return DM_OK; } @@ -88,11 +88,11 @@ ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr pBaseReq, Mess std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { LOGE("write pkg failed"); - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } return DM_OK; } @@ -111,10 +111,10 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt LOGE("GetTrustedDeviceList read node info failed!"); if (pRsp == nullptr) { LOGE("pRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } - pRsp->SetErrCode(DM_IPC_TRANSACTION_FAILED); - return DM_IPC_TRANSACTION_FAILED; + pRsp->SetErrCode(ERR_DM_IPC); + return ERR_DM_IPC; } deviceInfoVec.emplace_back(*pDmDeviceinfo); } @@ -196,11 +196,11 @@ ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Mess const DmSubscribeInfo dmSubscribeInfo = pReq->GetSubscribeInfo(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteRawData(&dmSubscribeInfo, sizeof(DmSubscribeInfo))) { LOGE("write subscribe info failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -218,11 +218,11 @@ ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Messa uint16_t subscribeId = pReq->GetSubscribeId(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteInt16((int16_t)subscribeId)) { LOGE("write subscribeId failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -231,7 +231,7 @@ ON_IPC_READ_RESPONSE(STOP_DEVICE_DISCOVER, MessageParcel &reply, std::shared_ptr { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -248,19 +248,19 @@ ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Messag if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { LOGE("write extra failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteInt32(authType)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -269,7 +269,7 @@ ON_IPC_READ_RESPONSE(AUTHENTICATE_DEVICE, MessageParcel &reply, std::shared_ptr< { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -283,11 +283,11 @@ ON_IPC_SET_REQUEST(UNAUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Mess std::string deviceId = deviceInfo.deviceId; if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { LOGE("write extra failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -303,7 +303,7 @@ ON_IPC_SET_REQUEST(VERIFY_AUTHENTICATION, std::shared_ptr pBaseReq, Mess std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string authPara = pReq->GetAuthPara(); if (!data.WriteString(authPara)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -320,7 +320,7 @@ ON_IPC_SET_REQUEST(SERVER_GET_DMFA_INFO, std::shared_ptr pBaseReq, Messa std::string packagename = pReq->GetPkgName(); if (!data.WriteString(packagename)) { LOGE("write pkgName failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -349,11 +349,11 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteInt32(action)) { LOGE("write action failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -374,11 +374,11 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -399,11 +399,11 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { LOGE("write extra failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -423,7 +423,7 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(DM_IPC_COPY_FAILED); + reply.WriteInt32(ERR_DM_IPC_COPY); return DM_OK; } switch (deviceState) { @@ -455,8 +455,8 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, MessageParcel &data, MessageParcel &reply) size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(DM_IPC_COPY_FAILED); - return DM_IPC_COPY_FAILED; + reply.WriteInt32(ERR_DM_IPC_COPY); + return ERR_DM_IPC_COPY; } DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceInfo); reply.WriteInt32(DM_OK); @@ -508,7 +508,7 @@ ON_IPC_CMD(SERVER_DEVICE_FA_NOTIFY, MessageParcel &data, MessageParcel &reply) DeviceManagerNotify::GetInstance().OnFaCall(packagename, paramJson); if (!reply.WriteInt32(DM_OK)) { LOGE("write return failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } diff --git a/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp index b8b944453c3a759ee483598639f0d64d070feca6..f23a628eddb3de9d86ca4c45331b4f057111e9cd 100644 --- a/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/mini/device_manager_impl.cpp @@ -44,7 +44,7 @@ int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::sh LOGI("DeviceManager::InitDeviceManager start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || dmInitCallback == nullptr) { LOGE("InitDeviceManager error: Invalid parameter"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } CommandDispatch::GetInstance().AddPkgName(pkgName); @@ -58,7 +58,7 @@ int32_t DeviceManagerImpl::UnInitDeviceManager(const std::string &pkgName) LOGI("DeviceManager::UnInitDeviceManager start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("InitDeviceManager error: Invalid parameter"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } CommandDispatch::GetInstance().DeletePkgName(pkgName); @@ -73,7 +73,7 @@ int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, cons LOGI("DeviceManager::GetTrustedDeviceList start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("GetTrustedDeviceList error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -101,7 +101,7 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi LOGI("DeviceManager::GetLocalDeviceInfo start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("GetLocalDeviceInfo error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -114,7 +114,7 @@ int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDevi if (rsp->GetErrCode() != DM_OK) { LOGE("GetLocalDeviceInfo error: failed ret: %d", rsp->GetErrCode()); - return DM_IPC_RESPOND_ERROR; + return ERR_DM_IPC_RESPOND; } info = rsp->GetLocalDeviceInfo(); @@ -128,7 +128,7 @@ int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, LOGI("DeviceManager::RegisterDevStateCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("RegisterDevStateCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); @@ -141,7 +141,7 @@ int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName LOGI("DeviceManager::UnRegisterDevStateCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnRegisterDevStateCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName); @@ -154,7 +154,7 @@ int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, cons LOGI("DeviceManager::StartDeviceDiscovery start, pkgName: %s", pkgName.c_str()); if (pkgName.empty() || callback == nullptr) { LOGE("StartDeviceDiscovery error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("DeviceManager StartDeviceDiscovery in, pkgName %s", pkgName.c_str()); @@ -182,7 +182,7 @@ int32_t DeviceManagerImpl::StopDeviceDiscovery(const std::string &pkgName, uint1 LOGI("DeviceManager::StopDeviceDiscovery start , pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("StopDeviceDiscovery error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } LOGI("StopDeviceDiscovery in, pkgName %s", pkgName.c_str()); @@ -212,7 +212,7 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ LOGI("DeviceManager::AuthenticateDevice start , pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("AuthenticateDevice error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::string strDeviceId = deviceInfo.deviceId; @@ -243,7 +243,7 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons LOGI("DeviceManager::UnAuthenticateDevice start , pkgName: %s, deviceId: %s", pkgName.c_str(), deviceId.c_str()); if (deviceId.empty()) { LOGE("UnAuthenticateDevice error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DmDeviceInfo deviceInfo; @@ -273,7 +273,7 @@ int32_t DeviceManagerImpl::RegisterDeviceManagerFaCallback(const std::string &pa LOGI("DeviceManager::RegisterDeviceManagerFaCallback start, pkgName: %s", packageName.c_str()); if (packageName.empty() || callback == nullptr) { LOGE("RegisterDeviceManagerFaCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(packageName, callback); @@ -286,7 +286,7 @@ int32_t DeviceManagerImpl::UnRegisterDeviceManagerFaCallback(const std::string & LOGI("DeviceManager::UnRegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("UnRegisterDeviceManagerFaCallback error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(pkgName); @@ -299,7 +299,7 @@ int32_t DeviceManagerImpl::VerifyAuthentication(const std::string &pkgName, cons LOGI("DeviceManager::VerifyAuthentication start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("VerifyAuthentication error: Invalid para"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } DeviceManagerNotify::GetInstance().RegisterVerifyAuthenticationCallback(pkgName, authPara, callback); @@ -328,7 +328,7 @@ int32_t DeviceManagerImpl::GetFaParam(const std::string &pkgName, DmAuthParam &d LOGI("DeviceManager::GetFaParam start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { LOGE("GetFaParam failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -350,7 +350,7 @@ int32_t DeviceManagerImpl::SetUserOperation(const std::string &pkgName, int32_t if (pkgName.empty()) { LOGE("VerifyAuthentication failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -376,7 +376,7 @@ int32_t DeviceManagerImpl::GetUdidByNetworkId(const std::string &pkgName, const { if (pkgName.empty()) { LOGE("GetUdidByNetworkId failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); @@ -403,7 +403,7 @@ int32_t DeviceManagerImpl::GetUuidByNetworkId(const std::string &pkgName, const { if (pkgName.empty()) { LOGE("GetUuidByNetworkId failed, pkgName is empty"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } std::shared_ptr req = std::make_shared(); diff --git a/interfaces/kits/js/include/native_devicemanager_js.h b/interfaces/kits/js/include/native_devicemanager_js.h index 8db0b602289e72159620283e76511310c2349748..aa109c6df036e452bd824e489aa9ba4e69982688 100644 --- a/interfaces/kits/js/include/native_devicemanager_js.h +++ b/interfaces/kits/js/include/native_devicemanager_js.h @@ -311,5 +311,6 @@ private: std::string bundleName_; static AuthAsyncCallbackInfo authAsyncCallbackInfo_; static AuthAsyncCallbackInfo verifyAsyncCallbackInfo_; + std::map errCodeInfo_; }; #endif // OHOS_DM_NATIVE_DEVICEMANAGER_JS_H diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index 82f76a4eff8696e4951bc449f4ffdc452ec992c0..947e04fa92f1b706262639aa265cdc381242667e 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -428,6 +428,38 @@ DeviceManagerNapi::DeviceManagerNapi(napi_env env, napi_value thisVar) : DmNativ { env_ = env; wrapper_ = nullptr; + errCodeInfo_.insert(std::pair(DM_OK, DM_OK_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_FAILED, DM_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_TIME_OUT, DM_TIME_OUT_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_NOT_INIT, DM_NOT_INIT_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_INIT_REPEATED, DM_INIT_REPEATED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_INIT_FAILED, DM_INIT_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_UNINIT_FAILED, DM_UNINIT_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_POINT_NULL, DM_POINT_NULL_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_INPUT_PARAMETER_EMPTY, DM_INPUT_PARAMETER_EMPTY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_NO_PERMISSION, DM_NO_PERMISSION_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_MALLOC_FAILED, DM_MALLOC_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_STRCOPY_FAILED, DM_STRCOPY_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_WRITE_FAILED, DM_WRITE_FAILED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_DISCOVERY, DM_DISCOVERY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_UNSUBSCRIBE_DP_EVENTS, DM_UNSUBSCRIBE_DP_EVENTS_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC, DM_IPC_ERR_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_WRITE, DM_IPC_WRITE_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_COPY, DM_IPC_COPY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_SEND_REQUEST, DM_IPC_SEND_REQUEST_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_REGISTER_FUNC, DM_IPC_REGISTER_FUNC_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_RESPOND, DM_IPC_RESPOND_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_IPC_WRITE_TOKEN, DM_IPC_WRITE_TOKEN_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_DISCOVERY_REPEATED, DM_DISCOVERY_REPEATED_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_BUSINESS_BUSY, DM_AUTH_BUSINESS_BUSY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_INPUT_PARAMETER_EMPTY, + DM_AUTH_INPUT_PARAMETER_EMPTY_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_OPEN_SESSION, DM_AUTH_OPEN_SESSION_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_OPPOSITE_REFUSED_REJECT, DM_OPPOSITE_REFUSED_REJECT_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_REFUSED_REJECT, DM_REFUSED_REJECT_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_DONT_AUTH, DM_AUTH_DONT_AUTH_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_AUTH_NOT_START, DM_AUTH_NOT_START_INFO)); + errCodeInfo_.insert(std::pair(ERR_DM_HICHAIN_CREATE_GROUP, DM_HICHAIN_CREATE_GROUP_INFO)); } DeviceManagerNapi::~DeviceManagerNapi() @@ -489,6 +521,16 @@ void DeviceManagerNapi::OnDiscoveryFailed(uint16_t subscribeId, int32_t failedRe napi_create_object(env_, &result); SetValueInt32(env_, "subscribeId", (int)subscribeId, result); SetValueInt32(env_, "reason", (int)failedReason, result); + std::map::iterator iter=errCodeInfo_.find(failedReason); + std::string tmp_iter; + if (iter != errCodeInfo_.end()) { + tmp_iter = iter->second; + LOGE("Found, the value is %s",tmp_iter.c_str()); + } else { + tmp_iter = "wyb success"; + LOGI("Do not found"); + } + SetValueUtf8String(env_, "errInfo", tmp_iter, result); OnEvent("discoverFail", DM_NAPI_ARGS_ONE, &result); } @@ -511,6 +553,16 @@ void DeviceManagerNapi::OnAuthResult(const std::string &deviceId, const std::str SetValueInt32(env_, "code", status, result[0]); SetValueInt32(env_, "reason", reason, result[0]); napi_get_undefined(env_, &result[1]); + std::map::iterator iter=errCodeInfo_.find(reason); + std::string tmp_iter; + if (iter != errCodeInfo_.end()) { + tmp_iter = iter->second; + LOGE("Found, the reason value is %s",tmp_iter.c_str()); + } else { + tmp_iter = "not found reason"; + LOGI("Do not found reason"); + } + SetValueUtf8String(env_, "errInfo", tmp_iter, result[0]); } napi_value callResult = nullptr; diff --git a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp index b8f538e81b4c7e2dca2786ae2940afdf32f217b4..ec9184e646baaf0e9e8d766ac24aad1d3366d383 100644 --- a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp +++ b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp @@ -158,11 +158,11 @@ int32_t AuthMessageProcessor::ParseMessage(const std::string &message) nlohmann::json jsonObject = nlohmann::json::parse(message, nullptr, false); if (jsonObject.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } if (!jsonObject.contains(TAG_TYPE)) { LOGE("err json string, first time"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t msgType = jsonObject[TAG_TYPE]; authResponseContext_->msgType = msgType; @@ -172,6 +172,24 @@ int32_t AuthMessageProcessor::ParseMessage(const std::string &message) ParseNegotiateMessage(jsonObject); break; case MSG_TYPE_REQ_AUTH: + if (!jsonObject.contains(TAG_INDEX) || !jsonObject.contains(TAG_DEVICE_ID) || + !jsonObject.contains(TAG_SLICE_NUM)) { + LOGE("err json string, first time"); + return ERR_DM_FAILED; + } + authResponseContext_->deviceId = jsonObject[TAG_DEVICE_ID]; + authResponseContext_->authType = jsonObject[TAG_AUTH_TYPE]; + authResponseContext_->appDesc = jsonObject[TAG_APP_DESCRIPTION]; + authResponseContext_->token = jsonObject[TAG_TOKEN]; + authResponseContext_->targetPkgName = jsonObject[TAG_TARGET]; + authResponseContext_->appName = jsonObject[TAG_APP_NAME]; + LOGI("AuthMessageProcessor::ParseAuthResponseMessage %s", authResponseContext_->deviceId.c_str()); + sliceNum = jsonObject[TAG_SLICE_NUM]; + if ((int32_t)authSplitJsonList_.size() < sliceNum) { + authSplitJsonList_.push_back(message); + } else { + ParseAuthRequestMessage(); + } return ParseAuthRequestMessage(jsonObject); break; case MSG_TYPE_RESP_AUTH: @@ -240,6 +258,25 @@ void AuthMessageProcessor::ParseAuthResponseMessage(nlohmann::json &json) LOGI("AuthMessageProcessor::ParseAuthResponseMessage "); } +int32_t AuthMessageProcessor::ParseAuthRequestMessage() +{ + nlohmann::json jsonObject = authSplitJsonList_.front(); + authResponseContext_->deviceId = jsonObject[TAG_DEVICE_ID]; + authResponseContext_->reply = jsonObject[TAG_REPLY]; + authResponseContext_->authType = jsonObject[TAG_AUTH_TYPE]; + LOGI("AuthMessageProcessor::ParseAuthResponseMessage %d", authResponseContext_->reply); + LOGI("AuthMessageProcessor::ParseAuthResponseMessage %s", authResponseContext_->deviceId.c_str()); + if (authResponseContext_->reply == AUTH_REPLY_ACCEPT) { + authResponseContext_->networkId = jsonObject[TAG_NET_ID]; + authResponseContext_->groupId = jsonObject[TAG_GROUP_ID]; + authResponseContext_->groupName = jsonObject[TAG_GROUP_NAME]; + authResponseContext_->requestId = jsonObject[TAG_REQUEST_ID]; + return ERR_DM_FAILED; + } + authSplitJsonList_.clear(); + return DM_OK; +} + void AuthMessageProcessor::ParseNegotiateMessage(const nlohmann::json &json) { if (json.contains(TAG_CRYPTO_SUPPORT)) { diff --git a/services/devicemanagerservice/src/authentication/auth_request_state.cpp b/services/devicemanagerservice/src/authentication/auth_request_state.cpp index ae2d967bdb80306dbf40a954d3acbc15e695692b..7163671855bc15d4ad2876b6d516fbfa100b2ccd 100644 --- a/services/devicemanagerservice/src/authentication/auth_request_state.cpp +++ b/services/devicemanagerservice/src/authentication/auth_request_state.cpp @@ -48,7 +48,7 @@ int32_t AuthRequestState::TransitionTo(std::shared_ptr state) std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } state->SetAuthManager(stateAuthManager); stateAuthManager->SetAuthRequestState(state); @@ -68,7 +68,7 @@ int32_t AuthRequestInitState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->EstablishAuthChannel(context_->deviceId); return DM_OK; @@ -84,7 +84,7 @@ int32_t AuthRequestNegotiateState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->StartNegotiate(context_->sessionId); return DM_OK; @@ -100,7 +100,7 @@ int32_t AuthRequestNegotiateDoneState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->SendAuthRequest(context_->sessionId); return DM_OK; @@ -116,7 +116,7 @@ int32_t AuthRequestReplyState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->StartRespAuthProcess(); return DM_OK; @@ -133,7 +133,7 @@ int32_t AuthRequestInputState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowStartAuthDialog(); return DM_OK; @@ -150,7 +150,7 @@ int32_t AuthRequestJoinState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AddMember(context_->deviceId); return DM_OK; @@ -166,7 +166,7 @@ int32_t AuthRequestNetworkState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->JoinNetwork(); return DM_OK; @@ -182,7 +182,7 @@ int32_t AuthRequestFinishState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AuthenticateFinish(); return DM_OK; diff --git a/services/devicemanagerservice/src/authentication/auth_response_state.cpp b/services/devicemanagerservice/src/authentication/auth_response_state.cpp index c2725a515ac61313384bb09a314e766b1cd860e2..50e566b0097ff71ae88d4522b24e29eb00ef8d0f 100644 --- a/services/devicemanagerservice/src/authentication/auth_response_state.cpp +++ b/services/devicemanagerservice/src/authentication/auth_response_state.cpp @@ -49,7 +49,7 @@ int32_t AuthResponseState::TransitionTo(std::shared_ptr state std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } state->SetAuthManager(stateAuthManager); stateAuthManager->SetAuthResponseState(state); @@ -80,7 +80,7 @@ int32_t AuthResponseNegotiateState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->RespNegotiate(context_->sessionId); return DM_OK; @@ -97,7 +97,7 @@ int32_t AuthResponseConfirmState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowConfigDialog(); return DM_OK; @@ -114,7 +114,7 @@ int32_t AuthResponseGroupState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->CreateGroup(); return DM_OK; @@ -130,7 +130,7 @@ int32_t AuthResponseShowState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowAuthInfoDialog(); return DM_OK; @@ -146,7 +146,7 @@ int32_t AuthResponseFinishState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AuthenticateFinish(); return DM_OK; diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index d075d871d5d7d06b11ff3a92e4422c3ae993c462..89bdd9b18e696eabe46a7367238176cd93f01f47 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -79,25 +79,25 @@ int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t au std::shared_ptr authentication = authenticationMap_[authType]; if (authentication == nullptr) { LOGE("DmAuthManager::AuthenticateDevice authType %d not support.", authType); - listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_AUTH_NOT_SUPPORT); - return DM_AUTH_NOT_SUPPORT; + listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, ERR_DM_FAILED); + return ERR_DM_FAILED; } if (authRequestState_ != nullptr || authResponseState_ != nullptr) { LOGE("DmAuthManager::AuthenticateDevice %s is request authentication.", pkgName.c_str()); - listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_AUTH_BUSINESS_BUSY); - return DM_AUTH_BUSINESS_BUSY; + listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, ERR_DM_AUTH_BUSINESS_BUSY); + return ERR_DM_AUTH_BUSINESS_BUSY; } if (!softbusConnector_->HaveDeviceInMap(deviceId)) { LOGE("AuthenticateDevice failed, the discoveryDeviceInfoMap_ not have this device"); - listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_AUTH_INPUT_FAILED); - return DM_AUTH_INPUT_FAILED; + listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, ERR_DM_AUTH_INPUT_PARAMETER_EMPTY); + return ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; } if (extra.empty()) { LOGE("AuthenticateDevice failed, extra is empty"); - listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_INPUT_PARA_EMPTY); - return DM_INPUT_PARA_EMPTY; + listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, ERR_DM_INPUT_PARAMETER_EMPTY); + return ERR_DM_INPUT_PARAMETER_EMPTY; } authMessageProcessor_ = std::make_shared(shared_from_this()); @@ -142,13 +142,13 @@ int32_t DmAuthManager::UnAuthenticateDevice(const std::string &pkgName, const st { if (pkgName.empty()) { LOGE(" DmAuthManager::UnAuthenticateDevice failed pkgName is null"); - return DM_FAILED; + return ERR_DM_FAILED; } std::string deviceUdid; int32_t ret = SoftbusConnector::GetUdidByNetworkId(deviceId.c_str(), deviceUdid); if (ret != DM_OK) { LOGE("UnAuthenticateDevice GetNodeKeyInfo failed"); - return DM_FAILED; + return ERR_DM_FAILED; } std::string groupId = ""; @@ -161,7 +161,7 @@ int32_t DmAuthManager::UnAuthenticateDevice(const std::string &pkgName, const st hiChainConnector_->DeleteGroup(groupId); } else { LOGE("DmAuthManager::UnAuthenticateDevice groupList.size = 0"); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } @@ -171,12 +171,12 @@ int32_t DmAuthManager::VerifyAuthentication(const std::string &authParam) LOGI("DmAuthManager::VerifyAuthentication"); if (authResponseContext_ == nullptr) { LOGE("authResponseContext_ is not init"); - return DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } std::shared_ptr ptr; if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { LOGE("DmAuthManager::authenticationMap_ is null"); - return DM_FAILED; + return ERR_DM_FAILED; } timerHeap_->DelTimer(INPUT_TIMEOUT_TASK); ptr = authenticationMap_[authResponseContext_->authType]; @@ -185,12 +185,12 @@ int32_t DmAuthManager::VerifyAuthentication(const std::string &authParam) case DM_OK: authRequestState_->TransitionTo(std::make_shared()); break; - case DM_AUTH_INPUT_FAILED: + case ERR_DM_AUTH_INPUT_PARAMETER_EMPTY: listener_->OnVerifyAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId, - DM_AUTH_INPUT_FAILED, ""); + ERR_DM_AUTH_INPUT_PARAMETER_EMPTY, ""); break; default: - authRequestContext_->reason = DM_AUTH_INPUT_FAILED; + authRequestContext_->reason = ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; authResponseContext_->state = authRequestState_->GetStateType(); authRequestState_->TransitionTo(std::make_shared()); break; @@ -216,7 +216,7 @@ void DmAuthManager::OnSessionOpened(int32_t sessionId, int32_t sessionSide, int3 std::shared_ptr authMessageProcessor = std::make_shared(shared_from_this()); std::shared_ptr authResponseContext = std::make_shared(); - authResponseContext->reply = DM_AUTH_BUSINESS_BUSY; + authResponseContext->reply = ERR_DM_AUTH_BUSINESS_BUSY; authMessageProcessor->SetResponseContext(authResponseContext); std::string message = authMessageProcessor->CreateSimpleMessage(MSG_TYPE_REQ_AUTH_TERMINATE); softbusConnector_->GetSoftbusSession()->SendData(sessionId, message); @@ -327,7 +327,7 @@ void DmAuthManager::OnGroupCreated(int64_t requestId, const std::string &groupId return; } if (groupId == "{}") { - authResponseContext_->reply = DM_HICHAIN_GROUP_CREATE_FAILED; + authResponseContext_->reply = ERR_DM_HICHAIN_CREATE_GROUP; authMessageProcessor_->SetResponseContext(authResponseContext_); std::string message = authMessageProcessor_->CreateSimpleMessage(MSG_TYPE_RESP_AUTH); softbusConnector_->GetSoftbusSession()->SendData(authResponseContext_->sessionId, message); @@ -358,7 +358,7 @@ void DmAuthManager::OnMemberJoin(int64_t requestId, int32_t status) if (status != DM_OK || authResponseContext_->requestId != requestId) { if (authRequestState_ != nullptr) { authResponseContext_->state = AuthState::AUTH_REQUEST_JOIN; - authRequestContext_->reason = DM_AUTH_INPUT_FAILED; + authRequestContext_->reason = ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; authRequestState_->TransitionTo(std::make_shared()); return; } @@ -375,13 +375,13 @@ int32_t DmAuthManager::HandleAuthenticateTimeout() authResponseContext_ = std::make_shared(); } authResponseContext_->state = authRequestState_->GetStateType(); - authRequestContext_->reason = DM_TIME_OUT; + authRequestContext_->reason = ERR_DM_TIME_OUT; authRequestState_->TransitionTo(std::make_shared()); } if (authResponseState_ != nullptr && authResponseState_->GetStateType() != AuthState::AUTH_RESPONSE_FINISH) { authResponseContext_->state = authResponseState_->GetStateType(); - authResponseContext_->reply = DM_TIME_OUT; + authResponseContext_->reply = ERR_DM_TIME_OUT; authResponseState_->TransitionTo(std::make_shared()); } LOGI("DmAuthManager::HandleAuthenticateTimeout start complete"); @@ -395,7 +395,7 @@ int32_t DmAuthManager::EstablishAuthChannel(const std::string &deviceId) LOGE("OpenAuthSession failed, stop the authentication"); authResponseContext_ = std::make_shared(); authResponseContext_->state = AuthState::AUTH_REQUEST_NEGOTIATE; - authRequestContext_->reason = DM_AUTH_OPEN_SESSION_FAILED; + authRequestContext_->reason = ERR_DM_AUTH_OPEN_SESSION; authRequestState_->TransitionTo(std::make_shared()); } return DM_OK; @@ -407,7 +407,7 @@ void DmAuthManager::StartNegotiate(const int32_t &sessionId) char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); authResponseContext_->localDeviceId = localDeviceId; - authResponseContext_->reply = DM_AUTH_NOT_AUTH; + authResponseContext_->reply = ERR_DM_REFUSED_REJECT; authResponseContext_->authType = authRequestContext_->authType; authResponseContext_->deviceId = authRequestContext_->deviceId; authMessageProcessor_->SetResponseContext(authResponseContext_); @@ -424,15 +424,15 @@ void DmAuthManager::RespNegotiate(const int32_t &sessionId) bool ret = hiChainConnector_->IsDevicesInGroup(authResponseContext_->localDeviceId, localDeviceId); if (!ret) { LOGE("DmAuthManager::EstablishAuthChannel device is in group"); - authResponseContext_->reply = DM_AUTH_PEER_REJECT; + authResponseContext_->reply = ERR_DM_OPPOSITE_REFUSED_REJECT; } else { - authResponseContext_->reply = DM_AUTH_NOT_AUTH; + authResponseContext_->reply = ERR_DM_REFUSED_REJECT; } std::shared_ptr authentication = authenticationMap_[authResponseContext_->authType]; if (authentication == nullptr) { LOGE("DmAuthManager::AuthenticateDevice authType %d not support.", authResponseContext_->authType); - authResponseContext_->reply = DM_AUTH_NOT_SUPPORT; + authResponseContext_->reply = ERR_DM_FAILED; } std::string message = authMessageProcessor_->CreateSimpleMessage(MSG_TYPE_RESP_NEGOTIATE); @@ -462,7 +462,7 @@ void DmAuthManager::SendAuthRequest(const int32_t &sessionId) if (authResponseContext_->cryptoSupport) { isCryptoSupport_ = true; } - if (authResponseContext_->reply == DM_AUTH_PEER_REJECT) { + if (authResponseContext_->reply == ERR_DM_OPPOSITE_REFUSED_REJECT) { authRequestState_->TransitionTo(std::make_shared()); return; } @@ -478,7 +478,7 @@ int32_t DmAuthManager::StartAuthProcess(const int32_t &action) LOGI("DmAuthManager:: StartAuthProcess"); if (authResponseContext_ == nullptr) { LOGI("Authenticate is not start"); - return DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } authResponseContext_->reply = action; @@ -503,7 +503,7 @@ void DmAuthManager::StartRespAuthProcess() } else { LOGE("do not accept"); authResponseContext_->state = AuthState::AUTH_REQUEST_REPLY; - authRequestContext_->reason = DM_AUTH_PEER_REJECT; + authRequestContext_->reason = ERR_DM_OPPOSITE_REFUSED_REJECT; authRequestState_->TransitionTo(std::make_shared()); } } @@ -523,7 +523,7 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) nlohmann::json jsonObj = nlohmann::json::parse(authResponseContext_->authToken, nullptr, false); if (jsonObj.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("DmAuthManager::AddMember start %s", authResponseContext_->authToken.c_str()); @@ -537,13 +537,13 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) timerHeap_->AddTimer(ADD_TIMEOUT_TASK, ADD_TIMEOUT, TimeOut, this); int32_t ret = hiChainConnector_->AddMember(deviceId, connectInfo); if (ret != 0) { - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("DmAuthManager::authRequestContext CancelDisplay start"); std::shared_ptr ptr; if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { LOGE("DmAuthManager::authenticationMap_ is null"); - return DM_FAILED; + return ERR_DM_FAILED; } ptr = authenticationMap_[authResponseContext_->authType]; ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this()); @@ -561,6 +561,10 @@ std::string DmAuthManager::GetConnectAddr(std::string deviceId) int32_t DmAuthManager::JoinNetwork() { LOGI("DmAuthManager JoinNetwork start"); + if (timerMap_.find(AUTHENTICATE_TIMEOUT_TASK) == timerMap_.end()) { + return ERR_DM_FAILED; + } + timerMap_[AUTHENTICATE_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT); timerHeap_->DelTimer(AUTHENTICATE_TIMEOUT_TASK); authResponseContext_->state = AuthState::AUTH_REQUEST_FINISH; authRequestContext_->reason = DM_OK; @@ -684,7 +688,7 @@ int32_t DmAuthManager::GetPinCode() nlohmann::json jsonObj = nlohmann::json::parse(authResponseContext_->authToken, nullptr, false); if (jsonObj.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } return jsonObj[PIN_CODE_KEY]; } @@ -733,12 +737,12 @@ int32_t DmAuthManager::GetAuthenticationParam(DmAuthParam &authParam) { if (dmAbilityMgr_ == nullptr) { LOGE("dmAbilityMgr_ is nullptr"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } dmAbilityMgr_->StartAbilityDone(); @@ -761,7 +765,7 @@ int32_t DmAuthManager::OnUserOperation(int32_t action) { if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } switch (action) { @@ -776,7 +780,7 @@ int32_t DmAuthManager::OnUserOperation(int32_t action) CancelDisplay(); break; case USER_OPERATION_TYPE_CANCEL_PINCODE_INPUT: - authRequestContext_->reason = DM_AUTH_DONT_AUTH; + authRequestContext_->reason = ERR_DM_AUTH_DONT_AUTH; authResponseContext_->state = authRequestState_->GetStateType(); AuthenticateFinish(); break; @@ -824,7 +828,7 @@ int32_t DmAuthManager::SetPageId(int32_t pageId) { if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } authResponseContext_->pageId = pageId; return DM_OK; @@ -834,7 +838,7 @@ int32_t DmAuthManager::SetReason(int32_t reason, int32_t state) { if (authResponseContext_ == nullptr) { LOGE("Authenticate is not start"); - return DM_AUTH_NOT_START; + return ERR_DM_AUTH_NOT_START; } if (state < AuthState::AUTH_REQUEST_FINISH) { authRequestContext_->reason = reason; diff --git a/services/devicemanagerservice/src/config/mini/pin_auth.cpp b/services/devicemanagerservice/src/config/mini/pin_auth.cpp index ccecb19116138610bf5d29f5d75ddfa5c542ed0d..e38953ac2e9797b7651c9b6b9d0cd1cd3ad2bbb0 100644 --- a/services/devicemanagerservice/src/config/mini/pin_auth.cpp +++ b/services/devicemanagerservice/src/config/mini/pin_auth.cpp @@ -38,7 +38,7 @@ int32_t PinAuth::CloseAuthInfo(const int32_t &pageId, std::shared_ptrCancelDisplay(); @@ -65,30 +65,30 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string return DM_OK; } LOGE("Peer rejection"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json authParamJson = nlohmann::json::parse(authParam, nullptr, false); if (authParamJson.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } nlohmann::json authTokenJson = nlohmann::json::parse(authToken, nullptr, false); if (authTokenJson.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } if (!authParamJson.contains(PIN_CODE_KEY) || !authTokenJson.contains(PIN_CODE_KEY)) { LOGE("err json string, first time"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t code = authTokenJson[PIN_CODE_KEY]; int32_t inputPinCode = authParamJson[PIN_CODE_KEY]; if (code == inputPinCode) { return DM_OK; } else if (code != inputPinCode && times_ < MAX_VERIFY_TIMES) { - return DM_AUTH_INPUT_FAILED; + return ERR_DM_AUTH_INPUT_PARAMETER_EMPTY; } else { - return DM_FAILED; + return ERR_DM_FAILED; } } } // namespace DistributedHardware diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index f1bb3a441aed7a57993f2ce7a0d3bf492c75416b..2d17775207e76f30be06a742dbb36bd5b6f853e5 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -96,7 +96,7 @@ int32_t HiChainConnector::CreateGroup(int64_t requestId, const std::string &grou { if (deviceGroupManager_ == nullptr) { LOGE("HiChainConnector::CreateGroup group manager is null, requestId %lld.", requestId); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } GroupInfo groupInfo; if (IsGroupCreated(groupName, groupInfo)) { @@ -116,13 +116,13 @@ int32_t HiChainConnector::CreateGroup(int64_t requestId, const std::string &grou int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->createGroup(userId, requestId, DM_PKG_NAME.c_str(), jsonObj.dump().c_str()); if (ret != 0) { LOGE("Failed to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId); - return DM_HICHAIN_GROUP_CREATE_FAILED; + return ERR_DM_HICHAIN_CREATE_GROUP; } return DM_OK; } @@ -147,7 +147,7 @@ int32_t HiChainConnector::GetGroupInfo(const std::string &queryParams, std::vect int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->getGroupInfo(userId, DM_PKG_NAME.c_str(), queryParams.c_str(), &groupVec, &num); if (ret != 0) { @@ -224,7 +224,7 @@ int32_t HiChainConnector::AddMember(const std::string &deviceId, const std::stri nlohmann::json jsonObject = nlohmann::json::parse(connectInfo, nullptr, false); if (jsonObject.is_discarded()) { LOGE("DecodeRequestAuth jsonStr error"); - return DM_FAILED; + return ERR_DM_FAILED; } char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); @@ -245,7 +245,7 @@ int32_t HiChainConnector::AddMember(const std::string &deviceId, const std::stri int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->addMemberToGroup(userId, requestId, DM_PKG_NAME.c_str(), tmpStr.c_str()); LOGI("HiChainConnector::AddMember completed"); @@ -281,7 +281,7 @@ void HiChainConnector::onError(int64_t requestId, int operationCode, int errorCo LOGI("HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", requestId, operationCode, errorCode); if (operationCode == GroupOperationCode::MEMBER_JOIN) { LOGE("Add Member To Group failed"); - hiChainConnectorCallback_->OnMemberJoin(requestId, DM_FAILED); + hiChainConnectorCallback_->OnMemberJoin(requestId, ERR_DM_FAILED); } if (operationCode == GroupOperationCode::GROUP_CREATE) { LOGE("Create group failed"); @@ -303,7 +303,7 @@ char *HiChainConnector::onRequest(int64_t requestId, int operationCode, const ch } nlohmann::json jsonObj; int32_t pinCode = hiChainConnectorCallback_->GetPinCode(); - if (pinCode == DM_FAILED) { + if (pinCode == ERR_DM_FAILED) { jsonObj[FIELD_CONFIRMATION] = REQUEST_REJECTED; } else { jsonObj[FIELD_CONFIRMATION] = REQUEST_ACCEPTED; @@ -345,32 +345,32 @@ int32_t HiChainConnector::GetRelatedGroups(const std::string &deviceId, std::vec int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->getRelatedGroups(userId, DM_PKG_NAME.c_str(), deviceId.c_str(), &returnGroups, &groupNum); if (ret != 0) { LOGE("HiChainConnector::GetRelatedGroups failed , ret: %d.", ret); - return DM_FAILED; + return ERR_DM_FAILED; } if (returnGroups == nullptr) { LOGE("HiChainConnector::GetRelatedGroups failed , returnGroups is nullptr"); - return DM_FAILED; + return ERR_DM_FAILED; } if (groupNum == 0) { LOGE("HiChainConnector::GetRelatedGroups group failed, groupNum is 0."); - return DM_FAILED; + return ERR_DM_FAILED; } std::string relatedGroups = std::string(returnGroups); nlohmann::json jsonObject = nlohmann::json::parse(relatedGroups); if (jsonObject.is_discarded()) { LOGE("returnGroups parse error"); - return DM_FAILED; + return ERR_DM_FAILED; } std::vector groupInfos = jsonObject.get>(); if (groupInfos.empty()) { LOGE("HiChainConnector::GetRelatedGroups group failed, groupInfos is empty."); - return DM_FAILED; + return ERR_DM_FAILED; } groupList = groupInfos; return DM_OK; @@ -380,7 +380,7 @@ int32_t HiChainConnector::GetSyncGroupList(std::vector &groupList, st { if (groupList.empty()) { LOGE("groupList is empty."); - return DM_FAILED; + return ERR_DM_FAILED; } for (auto group : groupList) { if (IsGroupInfoInvalid(group)) { @@ -446,7 +446,7 @@ int32_t HiChainConnector::DelMemberFromGroup(const std::string &groupId, const s int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->deleteMemberFromGroup(userId, requestId, DM_PKG_NAME.c_str(), deleteParams.c_str()); @@ -466,13 +466,13 @@ int32_t HiChainConnector::DeleteGroup(std::string &groupId) int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = deviceGroupManager_->deleteGroup(userId, requestId, DM_PKG_NAME.c_str(), disbandParams.c_str()); if (ret != 0) { LOGE("HiChainConnector::DeleteGroup failed , ret: %d.", ret); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } @@ -486,7 +486,7 @@ int32_t HiChainConnector::DeleteGroup(const int32_t userId, std::string &groupId int32_t ret = deviceGroupManager_->deleteGroup(userId, requestId, DM_PKG_NAME.c_str(), disbandParams.c_str()); if (ret != 0) { LOGE("HiChainConnector::DeleteGroup failed , ret: %d.", ret); - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; } @@ -497,7 +497,7 @@ int32_t HiChainConnector::DeleteTimeOutGroup(const char* deviceId) int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); if (userId < 0) { LOGE("get current process account user id failed"); - return DM_FAILED; + return ERR_DM_FAILED; } std::vector peerGroupInfoList; GetRelatedGroups(deviceId, peerGroupInfoList); @@ -509,7 +509,7 @@ int32_t HiChainConnector::DeleteTimeOutGroup(const char* deviceId) return DM_OK; } } - return DM_FAILED; + return ERR_DM_FAILED; } } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index e3e8586725a27cf7c8f364ae03beacbcf3911eb2..cf61c15bc3b361dfab452ee66ed3894f325a8e7f 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -188,12 +188,12 @@ int32_t SoftbusConnector::GetTrustedDeviceList(std::vector &device int32_t ret = GetAllNodeDeviceInfo(DM_PKG_NAME.c_str(), &nodeInfo, &infoNum); if (ret != 0) { LOGE("GetAllNodeDeviceInfo failed with ret %d", ret); - return DM_FAILED; + return ERR_DM_FAILED; } DmDeviceInfo *info = (DmDeviceInfo *)malloc(sizeof(DmDeviceInfo) * (infoNum)); if (info == nullptr) { FreeNodeInfo(nodeInfo); - return DM_MALLOC_ERROR; + return ERR_DM_MALLOC_FAILED; } DmDeviceInfo **pInfoList = &info; for (int32_t i = 0; i < infoNum; ++i) { @@ -215,7 +215,7 @@ int32_t SoftbusConnector::GetLocalDeviceInfo(DmDeviceInfo &deviceInfo) int32_t ret = GetLocalNodeDeviceInfo(DM_PKG_NAME.c_str(), &nodeBasicInfo); if (ret != 0) { LOGE("GetLocalNodeDeviceInfo failed with ret %d", ret); - return DM_FAILED; + return ERR_DM_FAILED; } CovertNodeBasicInfoToDmDevice(nodeBasicInfo, deviceInfo); LOGI("SoftbusConnector::GetLocalDeviceInfo success"); @@ -237,7 +237,7 @@ int32_t SoftbusConnector::StartDiscovery(const DmSubscribeInfo &dmSubscribeInfo) int32_t ret = ::StartDiscovery(DM_PKG_NAME.c_str(), &subscribeInfo, &softbusDiscoveryCallback_); if (ret != 0) { LOGE("StartDiscovery failed with ret %d.", ret); - return DM_DISCOVERY_FAILED; + return ERR_DM_DISCOVERY; } return DM_OK; } @@ -262,7 +262,7 @@ int32_t SoftbusConnector::GetUdidByNetworkId(const char *networkId, std::string GetNodeKeyInfo(DM_PKG_NAME.c_str(), networkId, NodeDeviceInfoKey::NODE_KEY_UDID, mUdid, sizeof(mUdid)); if (ret != DM_OK) { LOGE("GetUdidByNetworkId GetNodeKeyInfo failed"); - return DM_FAILED; + return ERR_DM_FAILED; } udid = (char *)mUdid; LOGI("SoftbusConnector::GetUdidByNetworkId completed"); @@ -277,7 +277,7 @@ int32_t SoftbusConnector::GetUuidByNetworkId(const char *networkId, std::string GetNodeKeyInfo(DM_PKG_NAME.c_str(), networkId, NodeDeviceInfoKey::NODE_KEY_UUID, mUuid, sizeof(mUuid)); if (ret != DM_OK) { LOGE("GetUuidByNetworkId GetNodeKeyInfo failed"); - return DM_FAILED; + return ERR_DM_FAILED; } uuid = (char *)mUuid; LOGI("SoftbusConnector::GetUuidByNetworkId completed"); @@ -342,12 +342,12 @@ int32_t SoftbusConnector::GetConnectionIpAddress(const std::string &deviceId, st auto iter = discoveryDeviceInfoMap_.find(deviceId); if (iter == discoveryDeviceInfoMap_.end()) { LOGE("deviceInfo not found by deviceId %s", GetAnonyString(deviceId).c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } DeviceInfo *deviceInfo = iter->second.get(); if (deviceInfo->addrNum <= 0 || deviceInfo->addrNum >= CONNECTION_ADDR_MAX) { LOGE("deviceInfo address num not valid, addrNum %d", deviceInfo->addrNum); - return DM_FAILED; + return ERR_DM_FAILED; } for (uint32_t i = 0; i < deviceInfo->addrNum; ++i) { // currently, only support CONNECT_ADDR_WLAN @@ -360,7 +360,7 @@ int32_t SoftbusConnector::GetConnectionIpAddress(const std::string &deviceId, st return DM_OK; } LOGE("failed to get ipAddress for deviceId %s", GetAnonyString(deviceId).c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } ConnectionAddr *SoftbusConnector::GetConnectAddrByType(DeviceInfo *deviceInfo, ConnectionAddrType type) diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp index d0022cdabc7b291765c7cc712f7298f31a9208ea..99605d7df6a9c93ecaca428d0e620c0883f9ed72 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp @@ -90,7 +90,7 @@ int32_t SoftbusSession::GetPeerDeviceId(int32_t sessionId, std::string &peerDevI if (ret == 0) { peerDevId = peerDeviceId; LOGI("GetPeerDeviceId success for session:%d, peerDeviceId:%s", sessionId, GetAnonyString(peerDevId).c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } LOGE("GetPeerDeviceId failed for session:%d", sessionId); peerDevId = ""; @@ -103,7 +103,7 @@ int32_t SoftbusSession::SendData(int32_t sessionId, std::string &message) nlohmann::json jsonObject = nlohmann::json::parse(message, nullptr, false); if (jsonObject.is_discarded()) { LOGE("extrasJson error"); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t msgType = jsonObject[TAG_TYPE]; LOGI("AuthMessageProcessor::ParseAuthRequestMessage msgType = %d", msgType); @@ -113,7 +113,7 @@ int32_t SoftbusSession::SendData(int32_t sessionId, std::string &message) int32_t ret = SendBytes(sessionId, message.c_str(), strlen(message.c_str())); if (ret != DM_OK) { LOGE("SendData Start failed"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("SendData Start success"); return DM_OK; diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp index ede24825c29d508955edae44f87b080fad7ea950..ebafb5d0b560551464ccbd45c1a0649768bf2d3b 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/devicemanagerservice/src/device_manager_service.cpp @@ -51,47 +51,47 @@ int32_t DeviceManagerService::Init() { if (intFlag_) { LOGE("Init failed, singleton cannot be initialized multiple times"); - return DM_INT_MULTIPLE; + return ERR_DM_INIT_REPEATED; } if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (softbusConnector_ == nullptr) { softbusConnector_ = std::make_shared(); if (softbusConnector_ == nullptr) { LOGE("Init failed, softbusConnector_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (listener_ == nullptr) { listener_ = std::make_shared(); if (softbusConnector_ == nullptr) { LOGE("Init failed, listener_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (hiChainConnector_ == nullptr) { hiChainConnector_ = std::make_shared(); if (hiChainConnector_ == nullptr) { LOGE("Init failed, hiChainConnector_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (deviceInfoMgr_ == nullptr) { deviceInfoMgr_ = std::make_shared(softbusConnector_); if (deviceInfoMgr_ == nullptr) { LOGE("Init failed, deviceInfoMgr_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (deviceStateMgr_ == nullptr) { deviceStateMgr_ = std::make_shared(softbusConnector_, listener_, hiChainConnector_); if (deviceStateMgr_ == nullptr) { LOGE("Init failed, deviceStateMgr_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } deviceStateMgr_->RegisterSoftbusStateCallback(); } @@ -99,14 +99,14 @@ int32_t DeviceManagerService::Init() discoveryMgr_ = std::make_shared(softbusConnector_, listener_); if (discoveryMgr_ == nullptr) { LOGE("Init failed, discoveryMgr_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } } if (authMgr_ == nullptr) { authMgr_ = std::make_shared(softbusConnector_, listener_, hiChainConnector_); if (authMgr_ == nullptr) { LOGE("Init failed, authMgr_ apply for failure"); - return DM_MAKE_SHARED_FAIL; + return ERR_DM_INIT_FAILED; } softbusConnector_->GetSoftbusSession()->RegisterSessionCallback(authMgr_); hiChainConnector_->RegisterHiChainCallback(authMgr_); @@ -135,15 +135,15 @@ int32_t DeviceManagerService::GetTrustedDeviceList(const std::string &pkgName, c { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("GetTrustedDeviceList failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("GetTrustedDeviceList failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return deviceInfoMgr_->GetTrustedDeviceList(pkgName, extra, deviceList); } @@ -152,11 +152,11 @@ int32_t DeviceManagerService::GetLocalDeviceInfo(DmDeviceInfo &info) { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } return deviceInfoMgr_->GetLocalDeviceInfo(info); } @@ -166,12 +166,12 @@ int32_t DeviceManagerService::GetUdidByNetworkId(const std::string &pkgName, con { if (!intFlag_) { LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("StartDeviceDiscovery failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } SoftbusConnector::GetUdidByNetworkId(netWorkId.c_str(), udid); return DM_OK; @@ -182,12 +182,12 @@ int32_t DeviceManagerService::GetUuidByNetworkId(const std::string &pkgName, con { if (!intFlag_) { LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("StartDeviceDiscovery failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } SoftbusConnector::GetUuidByNetworkId(netWorkId.c_str(), uuid); return DM_OK; @@ -198,15 +198,15 @@ int32_t DeviceManagerService::StartDeviceDiscovery(const std::string &pkgName, c { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("StartDeviceDiscovery failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("StartDeviceDiscovery failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); } @@ -215,15 +215,15 @@ int32_t DeviceManagerService::StopDeviceDiscovery(const std::string &pkgName, ui { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("StopDeviceDiscovery failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("StopDeviceDiscovery failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return discoveryMgr_->StopDeviceDiscovery(pkgName, subscribeId); } @@ -233,19 +233,19 @@ int32_t DeviceManagerService::AuthenticateDevice(const std::string &pkgName, int { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("AuthenticateDevice failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("AuthenticateDevice failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (deviceId.empty()) { LOGE("AuthenticateDevice failed, deviceId is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return authMgr_->AuthenticateDevice(pkgName, authType, deviceId, extra); } @@ -254,19 +254,19 @@ int32_t DeviceManagerService::UnAuthenticateDevice(const std::string &pkgName, c { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("UnAuthenticateDevice failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } if (pkgName.empty()) { LOGE("UnAuthenticateDevice failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (deviceId.empty()) { LOGE("UnAuthenticateDevice failed, deviceId is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } return authMgr_->UnAuthenticateDevice(pkgName, deviceId); } @@ -275,11 +275,11 @@ int32_t DeviceManagerService::VerifyAuthentication(const std::string &authParam) { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); - return DM_NO_PERMISSION; + return ERR_DM_NO_PERMISSION; } if (!intFlag_) { LOGE("VerifyAuthentication failed, singleton not init or init fail"); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } return authMgr_->VerifyAuthentication(authParam); } @@ -288,7 +288,7 @@ int32_t DeviceManagerService::GetFaParam(std::string &pkgName, DmAuthParam &auth { if (pkgName.empty()) { LOGE("GetFaParam failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (authMgr_ != nullptr) { authMgr_->GetAuthenticationParam(authParam); @@ -300,7 +300,7 @@ int32_t DeviceManagerService::SetUserOperation(std::string &pkgName, int32_t act { if (pkgName.empty()) { LOGE("SetUserOperation failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (authMgr_ != nullptr) { authMgr_->OnUserOperation(action); @@ -312,7 +312,7 @@ int32_t DeviceManagerService::RegisterDevStateCallback(const std::string &pkgNam { if (pkgName.empty()) { LOGE("RegisterDevStateCallback failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (deviceStateMgr_ != nullptr) { deviceStateMgr_->RegisterDevStateCallback(pkgName, extra); @@ -324,7 +324,7 @@ int32_t DeviceManagerService::UnRegisterDevStateCallback(const std::string &pkgN { if (pkgName.empty()) { LOGE("UnRegisterDevStateCallback failed, pkgName is empty"); - return DM_INPUT_PARA_EMPTY; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (deviceStateMgr_!= nullptr) { deviceStateMgr_->UnRegisterDevStateCallback(pkgName, extra); diff --git a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp b/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp index ec0cf6383517a148b4a72637abe91c47189bf9c0..862a853f8dc266e41787898f78e4332981ff6c20 100644 --- a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp +++ b/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp @@ -59,7 +59,7 @@ int32_t DmDiscoveryManager::StartDeviceDiscovery(const std::string &pkgName, con if (!discoveryQueue_.empty()) { if (pkgName == discoveryQueue_.front()) { LOGE("DmDiscoveryManager::StartDeviceDiscovery repeated, pkgName:%s", pkgName.c_str()); - return DM_DISCOVERY_REPEATED; + return ERR_DM_DISCOVERY_REPEATED; } else { LOGI("DmDiscoveryManager::StartDeviceDiscovery stop preview discovery first, the preview pkgName is %s", discoveryQueue_.front().c_str()); diff --git a/services/devicemanagerservice/src/dispatch/command_dispatch.cpp b/services/devicemanagerservice/src/dispatch/command_dispatch.cpp index 79d2ded4a33e690576ede872e18d175ccd14770e..9820d72deb69e43ca5c7b8bcd660e0699eb76006 100644 --- a/services/devicemanagerservice/src/dispatch/command_dispatch.cpp +++ b/services/devicemanagerservice/src/dispatch/command_dispatch.cpp @@ -42,7 +42,7 @@ int32_t CommandDispatch::MessageSendCmd(int32_t cmdCode, const std::shared_ptrSetErrCode(IpcIoPopInt32(&reply)); return DM_OK; @@ -71,7 +71,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND, IpcIo &reply, std::shared_ptr { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(IpcIoPopInt32(&reply)); return DM_OK; diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp index 5f29386cd0b973e096fabb371aed5ab9eb9cd1f5..53b01a1f3fc5300119e392779a1e030315c1059b 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp @@ -38,7 +38,7 @@ int32_t IpcServerListener::GetIdentityByPkgName(std::string &name, SvcIdentity * CommonSvcId svcId; if (IpcServerListenermgr::GetInstance().GetListenerByPkgName(name, &svcId) != DM_OK) { LOGE("get identity failed."); - return DM_FAILED; + return ERR_DM_FAILED; } CommonSvcToIdentity(&svcId, svc); return DM_OK; @@ -50,14 +50,14 @@ int32_t IpcServerListener::SendRequest(int32_t cmdCode, std::shared_ptr SvcIdentity svc; if (GetIdentityByPkgName(pkgName, &svc) != DM_OK) { LOGE("OnDeviceFound callback get listener failed."); - return DM_FAILED; + return ERR_DM_FAILED; } IpcIo io; uint8_t data[MAX_DM_IPC_LEN] = {0}; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, io, data, MAX_DM_IPC_LEN) != DM_OK) { LOGE("SetRequest failed cmdCode:%d", cmdCode); - return DM_FAILED; + return ERR_DM_FAILED; } if (::SendRequest(nullptr, svc, cmdCode, &io, nullptr, LITEIPC_FLAG_ONEWAY, nullptr) != DM_OK) { diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp index f8537b0e2f81b683b9d80ecaa9ac02f8eda25dfb..43b1920a91af0144f61420b43a75530db50a7e3f 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp @@ -26,7 +26,7 @@ int32_t IpcServerListenermgr::RegisterListener(std::string &pkgName, const Commo { if (pkgName == "" || svcId == nullptr) { LOGE("invalid param"); - return DM_FAILED; + return ERR_DM_FAILED; } LOGI("new listener register:%s", pkgName.c_str()); std::lock_guard autoLock(lock_); @@ -38,13 +38,13 @@ int32_t IpcServerListenermgr::GetListenerByPkgName(std::string &pkgName, CommonS { if (pkgName == "" || svcId == nullptr) { LOGE("invalid param"); - return DM_FAILED; + return ERR_DM_FAILED; } std::lock_guard autoLock(lock_); std::map::iterator iter = dmListenerMap_.find(pkgName); if (iter == dmListenerMap_.end()) { LOGE("listener not found for pkg:%s", pkgName.c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } *svcId = iter->second; return DM_OK; diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp index 23203801cd00406ab2720f81f58bc51d77e0dc4a..9831edb00c7124323680610bb9b56c79a042441c 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp @@ -53,7 +53,7 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi (void)data; if (arg == nullptr) { LOGE("package name is NULL."); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } CommonSvcId svcId = {0}; std::string pkgName = (const char *)arg; @@ -61,7 +61,7 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi LOGE("not found client by package name."); free(arg); arg = nullptr; - return DM_FAILED; + return ERR_DM_FAILED; } IpcServerListenermgr::GetInstance().UnregisterListener(pkgName); free(arg); @@ -85,7 +85,7 @@ int32_t RegisterDeviceManagerListener(IpcIo *req, IpcIo *reply) SvcIdentity *svc = IpcIoPopSvc(req); if (name == nullptr || svc == nullptr || len == 0) { LOGE("get para failed"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } CommonSvcId svcId = {0}; @@ -102,17 +102,17 @@ int32_t RegisterDeviceManagerListener(IpcIo *req, IpcIo *reply) #endif if (len == 0 || len > MALLOC_MAX_LEN) { LOGE("malloc length invalid!"); - return DM_MALLOC_ERROR; + return ERR_DM_MALLOC_FAILED; } char *pkgName = new char[len+1]; if (pkgName == nullptr) { LOGE("malloc failed!"); - return DM_MALLOC_ERROR; + return ERR_DM_MALLOC_FAILED; } if (strcpy_s(pkgName, len + 1, (const char *)name) != DM_OK) { LOGE("strcpy_s failed!"); delete[] pkgName; - return DM_COPY_FAILED; + return ERR_DM_STRCOPY_FAILED; } uint32_t cbId = 0; RegisterDeathCallback(NULL, sid, DeathCb, pkgName, &cbId); @@ -128,12 +128,12 @@ int32_t UnRegisterDeviceManagerListener(IpcIo *req, IpcIo *reply) std::string pkgName = (const char *)IpcIoPopString(req, &len); if (pkgName == "" || len == 0) { LOGE("get para failed"); - return DM_FAILED; + return ERR_DM_FAILED; } CommonSvcId svcId; if (IpcServerListenermgr::GetInstance().GetListenerByPkgName(pkgName, &svcId) != DM_OK) { LOGE("not found listener by package name."); - return DM_FAILED; + return ERR_DM_FAILED; } int32_t ret = IpcServerListenermgr::GetInstance().UnregisterListener(pkgName); if (ret == DM_OK) { diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index 0c29b78735af8fedfc66c70042e0a5602bdc2f70..5601b6af5635df963dc66d2869c09dc40dfb42ca 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -34,7 +34,7 @@ namespace DistributedHardware { ON_IPC_SET_REQUEST(SERVER_DEVICE_STATE_NOTIFY, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -60,7 +60,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &reply, std::shar { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -69,7 +69,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &reply, std::shar ON_IPC_SET_REQUEST(SERVER_DEVICE_FOUND, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -95,7 +95,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND, MessageParcel &reply, std::shared_ptr< { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -104,7 +104,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND, MessageParcel &reply, std::shared_ptr< ON_IPC_SET_REQUEST(SERVER_DISCOVER_FINISH, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string pkgName = pReq->GetPkgName(); @@ -129,7 +129,7 @@ ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH, MessageParcel &reply, std::shared_p { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -138,7 +138,7 @@ ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH, MessageParcel &reply, std::shared_p ON_IPC_SET_REQUEST(SERVER_AUTH_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -174,7 +174,7 @@ ON_IPC_READ_RESPONSE(SERVER_AUTH_RESULT, MessageParcel &reply, std::shared_ptrSetErrCode(reply.ReadInt32()); return DM_OK; @@ -183,7 +183,7 @@ ON_IPC_READ_RESPONSE(SERVER_AUTH_RESULT, MessageParcel &reply, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -215,7 +215,7 @@ ON_IPC_READ_RESPONSE(SERVER_VERIFY_AUTH_RESULT, MessageParcel &reply, std::share { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -224,7 +224,7 @@ ON_IPC_READ_RESPONSE(SERVER_VERIFY_AUTH_RESULT, MessageParcel &reply, std::share ON_IPC_SET_REQUEST(SERVER_DEVICE_FA_NOTIFY, std::shared_ptr pBaseReq, MessageParcel &data) { if (pBaseReq == nullptr) { - return DM_FAILED; + return ERR_DM_FAILED; } std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); @@ -246,7 +246,7 @@ ON_IPC_READ_RESPONSE(SERVER_DEVICE_FA_NOTIFY, MessageParcel &reply, std::shared_ { if (pBaseRsp == nullptr) { LOGE("pBaseRsp is null"); - return DM_FAILED; + return ERR_DM_FAILED; } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; @@ -263,7 +263,7 @@ ON_IPC_CMD(GET_TRUST_DEVICE_LIST, MessageParcel &data, MessageParcel &reply) DmDeviceInfo deviceInfo; if (!reply.WriteInt32(infoNum)) { LOGE("write infoNum failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } if (!deviceList.empty()) { for (; !deviceList.empty();) { @@ -272,13 +272,13 @@ ON_IPC_CMD(GET_TRUST_DEVICE_LIST, MessageParcel &data, MessageParcel &reply) if (!reply.WriteRawData(&deviceInfo, sizeof(DmDeviceInfo))) { LOGE("write subscribeInfo failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } } } if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } LOGI("GET_TRUST_DEVICE_LIST ok pkgName:%s, extra:%s", pkgName.c_str(), extra.c_str()); return DM_OK; @@ -291,7 +291,7 @@ ON_IPC_CMD(REGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &data, MessageParcel int32_t result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -302,7 +302,7 @@ ON_IPC_CMD(UNREGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &data, MessageParce int32_t result = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(pkgName); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -312,7 +312,7 @@ ON_IPC_CMD(START_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply) std::string pkgName = data.ReadString(); std::string extra = data.ReadString(); DmSubscribeInfo *subscribeInfo = (DmSubscribeInfo *)data.ReadRawData(sizeof(DmSubscribeInfo)); - int32_t result = DM_POINT_NULL; + int32_t result = ERR_DM_POINT_NULL; if (subscribeInfo != nullptr) { LOGI("pkgName:%s, subscribeId: %d", pkgName.c_str(), subscribeInfo->subscribeId); @@ -320,7 +320,7 @@ ON_IPC_CMD(START_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply) } if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -333,7 +333,7 @@ ON_IPC_CMD(STOP_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply) int32_t result = DeviceManagerService::GetInstance().StopDeviceDiscovery(pkgName, subscribeId); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -349,7 +349,7 @@ ON_IPC_CMD(AUTHENTICATE_DEVICE, MessageParcel &data, MessageParcel &reply) LOGE("AuthenticateDevice"); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } LOGE("AuthenticateDevice %d", result); return DM_OK; @@ -364,7 +364,7 @@ ON_IPC_CMD(UNAUTHENTICATE_DEVICE, MessageParcel &data, MessageParcel &reply) result = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -376,7 +376,7 @@ ON_IPC_CMD(VERIFY_AUTHENTICATION, MessageParcel &data, MessageParcel &reply) int32_t result = DeviceManagerService::GetInstance().VerifyAuthentication(authPara); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -393,7 +393,7 @@ ON_IPC_CMD(GET_LOCAL_DEVICE_INFO, MessageParcel &data, MessageParcel &reply) if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } LOGI("localDeviceInfo: %s", localDeviceInfo.deviceId); return DM_OK; @@ -408,11 +408,11 @@ ON_IPC_CMD(GET_UDID_BY_NETWORK, MessageParcel &data, MessageParcel &reply) if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } if (!reply.WriteString(udid)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -426,11 +426,11 @@ ON_IPC_CMD(GET_UUID_BY_NETWORK, MessageParcel &data, MessageParcel &reply) if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } if (!reply.WriteString(uuid)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } @@ -450,19 +450,19 @@ ON_IPC_CMD(SERVER_GET_DMFA_INFO, MessageParcel &data, MessageParcel &reply) !reply.WriteInt32(authParam.business) || !reply.WriteInt32(authParam.pincode) || !reply.WriteInt32(appIconLen) || !reply.WriteInt32(appThumbnailLen)) { LOGE("write reply failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (appIconLen > 0 && authParam.imageinfo.GetAppIcon() != nullptr) { if (!reply.WriteRawData(authParam.imageinfo.GetAppIcon(), appIconLen)) { LOGE("write appIcon failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } } if (appThumbnailLen > 0 && authParam.imageinfo.GetAppThumbnail() != nullptr) { if (!reply.WriteRawData(authParam.imageinfo.GetAppThumbnail(), appThumbnailLen)) { LOGE("write appThumbnail failed"); - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } } return DM_OK; @@ -475,7 +475,7 @@ ON_IPC_CMD(SERVER_USER_AUTH_OPERATION, MessageParcel &data, MessageParcel &reply int result = DeviceManagerService::GetInstance().SetUserOperation(packageName, action); if (!reply.WriteInt32(action)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return result; } @@ -487,7 +487,7 @@ ON_IPC_CMD(REGISTER_DEV_STATE_CALLBACK, MessageParcel &data, MessageParcel &repl int result = DeviceManagerService::GetInstance().RegisterDevStateCallback(packageName, extra); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return result; } @@ -499,7 +499,7 @@ ON_IPC_CMD(UNREGISTER_DEV_STATE_CALLBACK, MessageParcel &data, MessageParcel &re int result = DeviceManagerService::GetInstance().UnRegisterDevStateCallback(packageName, extra); if (!reply.WriteInt32(result)) { LOGE("write result failed"); - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return result; } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp index c61e4228472031f1e27d35afc0f6fd828f1ef1b5..11837920b31167cdbb71cf8dc8fa43565ad17836 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp @@ -28,17 +28,17 @@ int32_t IpcServerClientProxy::SendCmd(int32_t cmdCode, std::shared_ptr r sptr remote = Remote(); if (remote == nullptr) { LOGE("remote service null"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } MessageParcel data; MessageParcel reply; MessageOption option; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { - return DM_IPC_FAILED; + return ERR_DM_IPC; } if (remote->SendRequest((uint32_t)cmdCode, data, reply, option) != DM_OK) { LOGE("SendRequest fail, cmd:%d", cmdCode); - return DM_IPC_FAILED; + return ERR_DM_IPC; } return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp index 81dcc23992fa2ba14f14b386464e6d43551ad14f..5589b297447af2651d94721607385b38e839e5e4 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp @@ -27,7 +27,7 @@ int32_t IpcServerListener::SendRequest(int32_t cmdCode, std::shared_ptr sptr listener = IpcServerStub::GetInstance().GetDmListener(pkgName); if (listener == nullptr) { LOGI("cannot get listener for package:%s.", pkgName.c_str()); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return listener->SendCmd(cmdCode, req, rsp); } @@ -42,7 +42,7 @@ int32_t IpcServerListener::SendAll(int32_t cmdCode, std::shared_ptr req, sptr listener = iface_cast(remote); if (listener == nullptr) { LOGI("cannot get listener for package:%s.", pkgName.c_str()); - return DM_FAILED; + return ERR_DM_FAILED; } listener->SendCmd(cmdCode, req, rsp); } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index e95e98fc5452780a59fb2acd18ba40d61ffddf7d..178a0b5e17a365e165b9678a9012b210d9fbea8a 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -88,7 +88,7 @@ int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa } int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd((int32_t)code, data, reply); - if (ret == DM_IPC_NOT_REGISTER_FUNC) { + if (ret == ERR_DM_REGISTER_FUNC) { LOGW("unsupported code: %d", code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } @@ -103,11 +103,11 @@ int32_t IpcServerStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std MessageOption option; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { LOGE("set request cmd failed"); - return DM_IPC_FAILED; + return ERR_DM_IPC; } int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - if (ret == DM_IPC_NOT_REGISTER_FUNC) { + if (ret == ERR_DM_REGISTER_FUNC) { LOGW("unsupported code: %d", cmdCode); return IPCObjectStub::OnRemoteRequest(cmdCode, data, reply, option); } @@ -123,12 +123,12 @@ int32_t IpcServerStub::RegisterDeviceManagerListener(std::string &pkgName, sptr< { if (pkgName.empty() || listener == nullptr) { LOGE("RegisterDeviceManagerListener error: input parameter invalid."); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } if (!DeviceManagerService::GetInstance().IsServiceInitialized()) { LOGE("Device manager service has not been initialized or initialized failed."); - return DM_NOT_INIT; + return ERR_DM_NOT_INIT; } LOGI("Register device manager listener for pakage name: %s", pkgName.c_str()); @@ -147,7 +147,7 @@ int32_t IpcServerStub::RegisterDeviceManagerListener(std::string &pkgName, sptr< appRecipient_[pkgName] = appRecipient; } catch (const std::bad_alloc &e) { LOGE("new AppDeathRecipient failed"); - return DM_MALLOC_ERROR; + return ERR_DM_MALLOC_FAILED; } return DM_OK; } @@ -156,7 +156,7 @@ int32_t IpcServerStub::UnRegisterDeviceManagerListener(std::string &pkgName) { if (pkgName.empty()) { LOGE("Error: parameter invalid"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } LOGI("In, pkgName: %s", pkgName.c_str()); std::lock_guard autoLock(listenerLock_); diff --git a/test/unittest/UTTest_auth_message_processor.cpp b/test/unittest/UTTest_auth_message_processor.cpp index c484f6a33496397c81311fbaf27c25d7e77b8578..7b70dcb0d5b0e4df089caffceed24a5540f20809 100644 --- a/test/unittest/UTTest_auth_message_processor.cpp +++ b/test/unittest/UTTest_auth_message_processor.cpp @@ -282,6 +282,9 @@ HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_001, testing::ext::Te jsonThumbnail[TAG_GROUP_ID] = authResponseContext->groupId; jsonThumbnail[TAG_GROUP_NAME] = authResponseContext->groupName; jsonThumbnail[TAG_REQUEST_ID] = authResponseContext->requestId; + authMessageProcessor->authSplitJsonList_.push_back(jsonThumbnail); + int32_t ret = authMessageProcessor->ParseAuthRequestMessage(); + ASSERT_EQ(ret, ERR_DM_FAILED); int32_t ret = authMessageProcessor->ParseAuthRequestMessage(jsonThumbnail); ASSERT_EQ(ret, DM_FAILED); } diff --git a/test/unittest/UTTest_auth_request_state.cpp b/test/unittest/UTTest_auth_request_state.cpp index 4669afacd697e230bb56346ba05d2d4b5f527e5a..1c0daa442a996965b6a22b16cc390317b5a4b9da 100644 --- a/test/unittest/UTTest_auth_request_state.cpp +++ b/test/unittest/UTTest_auth_request_state.cpp @@ -152,7 +152,7 @@ HWTEST_F(AuthRequestStateTest, SetAuthManager_002, testing::ext::TestSize.Level0 * @tc.name: AuthRequestNegotiateState::TransitionTo_001 * @tc.desc: 1 set authManager to null * 2 call AuthRequestInitState::TransitionTo with authManager = null - * 4 check ret is DM_FAILED + * 4 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -164,7 +164,7 @@ HWTEST_F(AuthRequestStateTest, TransitionTo_001, testing::ext::TestSize.Level0) authManager = nullptr; authRequestState->authManager_ = authManager; int32_t ret = authRequestState->TransitionTo(std::make_shared()); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -215,7 +215,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_001, testing::ext::TestSize.Level0) * @tc.name: AuthRequestInitState::Enter_001 * @tc.desc: 1 set authManager to null * 2 call AuthRequestInitState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -227,14 +227,14 @@ HWTEST_F(AuthRequestStateTest, Enter_001, testing::ext::TestSize.Level0) authManager = nullptr; authRequestState->SetAuthManager(authManager); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: AuthRequestInitState::Enter_002 * @tc.desc: 1 set authManager not null * 2 call AuthRequestInitState::Enter with authManager != null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -272,7 +272,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_002, testing::ext::TestSize.Level0) * @tc.name: AuthRequestNegotiateState::Enter_001 * @tc.desc: 1 set authManager to null * 2 call AuthRequestNegotiateState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -283,7 +283,7 @@ HWTEST_F(AuthRequestStateTest, Enter_003, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -334,7 +334,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_003, testing::ext::TestSize.Level0) * @tc.name: AuthRequestNegotiateDoneState::Enter_005 * @tc.desc: 1 set authManager to null * 2 call AuthRequestNegotiateDoneState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -345,7 +345,7 @@ HWTEST_F(AuthRequestStateTest, Enter_005, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -395,7 +395,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_004, testing::ext::TestSize.Level0) * @tc.name: AuthRequestReplyState::Enter_007 * @tc.desc: 1 set authManager to null * 2 call AuthRequestReplyState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -406,7 +406,7 @@ HWTEST_F(AuthRequestStateTest, Enter_007, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -457,7 +457,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_005, testing::ext::TestSize.Level0) * @tc.name: AuthRequestInputState::Enter_009 * @tc.desc: 1 set authManager to null * 2 call AuthRequestInputState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -468,7 +468,7 @@ HWTEST_F(AuthRequestStateTest, Enter_009, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -508,7 +508,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_006, testing::ext::TestSize.Level0) * @tc.name: AuthRequestJoinState::Enter_011 * @tc.desc: 1 set authManager to null * 2 call AuthRequestJoinState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -519,7 +519,7 @@ HWTEST_F(AuthRequestStateTest, Enter_011, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -573,7 +573,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_007, testing::ext::TestSize.Level0) * @tc.name: AuthRequestNetworkState::Enter_013 * @tc.desc: 1 set authManager to null * 2 call AuthRequestNetworkState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -584,7 +584,7 @@ HWTEST_F(AuthRequestStateTest, Enter_013, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -632,7 +632,7 @@ HWTEST_F(AuthRequestStateTest, GetStateType_008, testing::ext::TestSize.Level0) * @tc.name: AuthRequestFinishState::Enter_015 * @tc.desc: 1 set authManager to null * 2 call AuthRequestFinishState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -643,7 +643,7 @@ HWTEST_F(AuthRequestStateTest, Enter_015, testing::ext::TestSize.Level0) std::shared_ptr authRequestState = std::make_shared(); authRequestState->SetAuthManager(nullptr); int32_t ret = authRequestState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_auth_response_state.cpp b/test/unittest/UTTest_auth_response_state.cpp index 1e85f56adce0b70ac44e0a598aa2d7731c899608..fd04cb8e30eb678bce04f8f106aab8616dbfcb6e 100644 --- a/test/unittest/UTTest_auth_response_state.cpp +++ b/test/unittest/UTTest_auth_response_state.cpp @@ -115,7 +115,7 @@ HWTEST_F(AuthResponseStateTest, SetAuthManager_002, testing::ext::TestSize.Level * @tc.name: AuthResponseInitState::TransitionTo_001 * @tc.desc: 1 set authManager to null * 2 call AuthResponseInitState::TransitionTo with authManager = null - * 4 check ret is DM_FAILED + * 4 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -127,7 +127,7 @@ HWTEST_F(AuthResponseStateTest, TransitionTo_001, testing::ext::TestSize.Level0) authManager = nullptr; authResponseState->authManager_ = authManager; int32_t ret = authResponseState->TransitionTo(std::make_shared()); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -200,7 +200,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_002, testing::ext::TestSize.Level0) * @tc.name: AuthResponseNegotiateState::Enter_002 * @tc.desc: 1 set authManager to null * 2 call AuthResponseNegotiateState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -212,7 +212,7 @@ HWTEST_F(AuthResponseStateTest, Enter_002, testing::ext::TestSize.Level0) authManager = nullptr; authResponseState->SetAuthManager(authManager); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -266,7 +266,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_003, testing::ext::TestSize.Level0) * @tc.name: AuthResponseConfirmState::Enter_004 * @tc.desc: 1 set authManager to null * 2 call AuthResponseConfirmState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -277,7 +277,7 @@ HWTEST_F(AuthResponseStateTest, Enter_004, testing::ext::TestSize.Level0) std::shared_ptr authResponseState = std::make_shared(); authResponseState->SetAuthManager(nullptr); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -317,7 +317,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_004, testing::ext::TestSize.Level0) * @tc.name: AuthResponseGroupState::Enter_006 * @tc.desc: 1 set authManager to null * 2 call AuthResponseGroupState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -328,7 +328,7 @@ HWTEST_F(AuthResponseStateTest, Enter_006, testing::ext::TestSize.Level0) std::shared_ptr authResponseState = std::make_shared(); authResponseState->SetAuthManager(nullptr); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -369,7 +369,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_005, testing::ext::TestSize.Level0) * @tc.name: AuthResponseShowState::Enter_008 * @tc.desc: 1 set authManager to null * 2 call AuthResponseShowState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -380,7 +380,7 @@ HWTEST_F(AuthResponseStateTest, Enter_008, testing::ext::TestSize.Level0) std::shared_ptr authResponseState = std::make_shared(); authResponseState->SetAuthManager(nullptr); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -420,7 +420,7 @@ HWTEST_F(AuthResponseStateTest, GetStateType_006, testing::ext::TestSize.Level0) * @tc.name: AuthResponseFinishState::Enter_010 * @tc.desc: 1 set authManager to null * 2 call AuthResponseFinishState::Enter with authManager = null - * 3 check ret is DM_FAILED + * 3 check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -431,7 +431,7 @@ HWTEST_F(AuthResponseStateTest, Enter_010, testing::ext::TestSize.Level0) std::shared_ptr authResponseState = std::make_shared(); authResponseState->SetAuthManager(nullptr); int32_t ret = authResponseState->Enter(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_device_manager_impl.cpp b/test/unittest/UTTest_device_manager_impl.cpp index 259a3b98e22b9cd72633a28d1ab9efddfade3735..8ac00a0d93668f93a82d50f47f8459b7e7d3e665 100644 --- a/test/unittest/UTTest_device_manager_impl.cpp +++ b/test/unittest/UTTest_device_manager_impl.cpp @@ -59,7 +59,7 @@ namespace { /** * @tc.name: InitDeviceManager_001 * @tc.desc: 1. call DeviceManagerImpl::InitDeviceManager with packName = null, dmInitCallback = nullprt - * 2. check ret is DM_INVALID_VALUE + * 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -70,8 +70,8 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_001, testing::ext::TestSize.Le std::string packName = ""; std::shared_ptr dmInitCallback = nullptr; int32_t ret= DeviceManager::GetInstance().InitDeviceManager(packName, dmInitCallback); - // 2. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -91,7 +91,7 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_002, testing::ext::TestSize.Le std::string packName = "com.ohos.test"; // set dmInitCallback not null std::shared_ptr callback = std::make_shared(); - // 2. MOCK IpcClientProxy Init return DM_FAILED + // 2. MOCK IpcClientProxy Init return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_OK)); @@ -106,9 +106,9 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_002, testing::ext::TestSize.Le * @tc.name: InitDeviceManager_003 * @tc.desc: 1. set packName not null * set dmInitCallback not null - * 2. MOCK IpcClientProxy Init return DM_INIT_FAILED + * 2. MOCK IpcClientProxy Init return ERR_DM_INIT_FAILED * 3. call DeviceManagerImpl::InitDeviceManager with parameter - * 4. check ret is DM_INIT_FAILED + * 4. check ret is ERR_DM_INIT_FAILED * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -119,21 +119,21 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_003, testing::ext::TestSize.Le std::string packName = "com.ohos.test"; // set dmInitCallback not null std::shared_ptr callback = std::make_shared(); - // 2. MOCK IpcClientProxy Init return DM_FAILED + // 2. MOCK IpcClientProxy Init return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; - EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_INIT_FAILED)); + EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED)); // 3. call DeviceManagerImpl::InitDeviceManager with parameter int32_t ret= DeviceManager::GetInstance().InitDeviceManager(packName, callback); - // 4. check ret is DM_INIT_FAILED - ASSERT_EQ(ret, DM_INIT_FAILED); + // 4. check ret is ERR_DM_INIT_FAILED + ASSERT_EQ(ret, ERR_DM_INIT_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } /** * @tc.name: InitDeviceManager_004 * @tc.desc: 1. call DeviceManagerImpl::InitDeviceManager with packName not null, dmInitCallback = nullprt - * 2. check ret is DM_INVALID_VALUE + * 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -144,14 +144,14 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_004, testing::ext::TestSize.Le std::string packName = "com.ohos.test"; std::shared_ptr callback = nullptr; int32_t ret= DeviceManager::GetInstance().InitDeviceManager(packName, callback); - // 2. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: InitDeviceManager_005 * @tc.desc: 1. call DeviceManagerImpl::InitDeviceManager with packName not null, dmInitCallback = nullprt - * 2. check ret is DM_INVALID_VALUE + * 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -162,14 +162,14 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager_005, testing::ext::TestSize.Le std::string packName = ""; std::shared_ptr callback = std::make_shared(); int32_t ret= DeviceManager::GetInstance().InitDeviceManager(packName, callback); - // 2. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnInitDeviceManager_001 * @tc.desc: 1. call DeviceManagerImpl::InitDeviceManager with packName not null, dmInitCallback = nullprt - * 2. check ret is DM_INVALID_VALUE + * 2. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -180,16 +180,16 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_001, testing::ext::TestSize. std::string packName = ""; // 2. call DeviceManagerImpl::InitDeviceManager with parameter int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnInitDeviceManager_002 * @tc.desc: 1. set packName not null - * 2. MOCK IpcClientProxy UnInit return DM_UNINIT_FAILED + * 2. MOCK IpcClientProxy UnInit return ERR_DM_UNINIT_FAILED * 3. call DeviceManagerImpl::UnInitDeviceManager with parameter - * 4. check ret is DM_UNINIT_FAILED + * 4. check ret is ERR_DM_UNINIT_FAILED * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -201,10 +201,10 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_002, testing::ext::TestSize. // 2. call DeviceManagerImpl::InitDeviceManager with parameter std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_UNINIT_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_UNINIT_FAILED)); int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName); - // 3. check ret is DM_UNINIT_FAILED - ASSERT_EQ(ret, DM_UNINIT_FAILED); + // 3. check ret is ERR_DM_UNINIT_FAILED + ASSERT_EQ(ret, ERR_DM_UNINIT_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -235,9 +235,9 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_003, testing::ext::TestSize. /** * @tc.name: UnInitDeviceManager_004 * @tc.desc: 1. set packName not null - * 2. MOCK IpcClientProxy UnInit return DM_INIT_FAILED + * 2. MOCK IpcClientProxy UnInit return ERR_DM_INIT_FAILED * 3. call DeviceManagerImpl::UnInitDeviceManager with parameter - * 4. check ret is DM_UNINIT_FAILED + * 4. check ret is ERR_DM_UNINIT_FAILED * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -249,19 +249,19 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_004, testing::ext::TestSize. // 2. call DeviceManagerImpl::InitDeviceManager with parameter std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_INIT_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED)); int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName); - // 3. check ret is DM_UNINIT_FAILED - ASSERT_EQ(ret, DM_UNINIT_FAILED); + // 3. check ret is ERR_DM_UNINIT_FAILED + ASSERT_EQ(ret, ERR_DM_UNINIT_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } /** * @tc.name: UnInitDeviceManager_005 * @tc.desc: 1. set packName not null - * 2. MOCK IpcClientProxy UnInit return DM_INIT_FAILED + * 2. MOCK IpcClientProxy UnInit return ERR_DM_INIT_FAILED * 3. call DeviceManagerImpl::UnInitDeviceManager with parameter - * 4. check ret is DM_UNINIT_FAILED + * 4. check ret is ERR_DM_UNINIT_FAILED * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -273,10 +273,10 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_005, testing::ext::TestSize. // 2. call DeviceManagerImpl::InitDeviceManager with parameter std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_INIT_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED)); int32_t ret= DeviceManager::GetInstance().UnInitDeviceManager(packName); - // 3. check ret is DM_UNINIT_FAILED - ASSERT_EQ(ret, DM_UNINIT_FAILED); + // 3. check ret is ERR_DM_UNINIT_FAILED + ASSERT_EQ(ret, ERR_DM_UNINIT_FAILED); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -286,7 +286,7 @@ HWTEST_F(DeviceManagerImplTest, UnInitDeviceManager_005, testing::ext::TestSize. * set extra null * set deviceList null * 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -301,8 +301,8 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_001, testing::ext::TestSize std::vector deviceList; // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -310,9 +310,9 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_001, testing::ext::TestSize * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -325,15 +325,15 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_002, testing::ext::TestSize std::string extra = ""; // set deviceList null std::vector deviceList; - // 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_SEND_REQUEST_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC_SEND_REQUEST)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -374,9 +374,9 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_003, testing::ext::TestSize * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -389,15 +389,15 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_004, testing::ext::TestSize std::string extra = "test"; // set deviceList null std::vector deviceList; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); // 3. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -407,7 +407,7 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_004, testing::ext::TestSize * set extra null * set deviceList null * 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -422,8 +422,8 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_005, testing::ext::TestSize std::vector deviceList; // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetTrustedDeviceList(packName, extra, deviceList); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } @@ -433,7 +433,7 @@ HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_005, testing::ext::TestSize * set extra null * set deviceList null * 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -444,14 +444,14 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_001, testing::ext::TestSize.L std::string packName = "com.ohos.test"; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1).WillOnce(testing::Return(DM_OK)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED + // 3. check ret is ERR_DM_IPC_SEND_REQUEST ASSERT_EQ(ret, DM_OK); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -461,9 +461,9 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_001, testing::ext::TestSize.L * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -474,15 +474,15 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_002, testing::ext::TestSize.L std::string packName = "com.ohos.test"; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return DM_IPC_SEND_REQUEST_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_IPC_SEND_REQUEST std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_SEND_REQUEST_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC_SEND_REQUEST)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -521,9 +521,9 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_003, testing::ext::TestSize.L * @tc.desc: 1. set packName not null * set extra null * set deviceList null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -534,15 +534,15 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_004, testing::ext::TestSize.L std::string packName = "com.ohos.test"; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); // 3. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -552,7 +552,7 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_004, testing::ext::TestSize.L * set extra null * set deviceList null * 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -563,15 +563,15 @@ HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_005, testing::ext::TestSize.L std::string packName = ""; // set extra null DmDeviceInfo info; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::GetTrustedDeviceList with parameter int32_t ret= DeviceManager::GetInstance().GetLocalDeviceInfo(packName, info); // 3. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -597,8 +597,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_001, testing::ext::Test std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -632,7 +632,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_002, testing::ext::Test * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -647,8 +647,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_003, testing::ext::Test std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(pkgName, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -673,7 +673,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_004, testing::ext::Test // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(pkgName, extra, callback); // 3. check ret is DM_OK - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -682,7 +682,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_004, testing::ext::Test * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -697,15 +697,15 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_005, testing::ext::Test std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(pkgName, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_001 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -716,15 +716,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_001, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_002 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -735,15 +735,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_002, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_003 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -754,15 +754,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_003, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_004 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -773,15 +773,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_004, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_005 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -792,8 +792,8 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_005, testing::ext::Te std::string packName = ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -802,7 +802,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_005, testing::ext::Te * set subscribeInfo null * set callback null * 2. call DeviceManagerImpl::StartDeviceDiscovery with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -818,8 +818,8 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_001, testing::ext::TestSize std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::StartDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -828,7 +828,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_001, testing::ext::TestSize * set subscribeInfo null * set callback null * 2. call DeviceManagerImpl::StartDeviceDiscovery with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -844,8 +844,8 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_002, testing::ext::TestSize std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::StartDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -867,15 +867,15 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_003, testing::ext::TestSize DmSubscribeInfo subscribeInfo; std::string extra = "test"; std::shared_ptr callback = std::make_shared(); ; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -917,9 +917,9 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_004, testing::ext::TestSize * @tc.desc: 1. set packName not null * set subscribeInfo null * set callback not null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::StartDeviceDiscovery with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -933,15 +933,15 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_005, testing::ext::TestSize DmSubscribeInfo subscribeInfo; // set callback not null std::shared_ptr callback = std::make_shared(); - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StartDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); // 4. check ret is DEVICEMANAGER_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -950,7 +950,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery_005, testing::ext::TestSize * @tc.desc: 1. set packName null * set subscribeId is 0 * 2. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -963,17 +963,17 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_001, testing::ext::TestSize. uint16_t subscribeId = 0; // 2. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: StopDeviceDiscovery_002 * @tc.desc: 1. set packName not null * set subscribeId is 0 - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 2. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -984,15 +984,15 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_002, testing::ext::TestSize. std::string packName = "com.ohos.test"; // set subscribeInfo is 0 uint16_t subscribeId = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1029,9 +1029,9 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_003, testing::ext::TestSize. * @tc.name: StopDeviceDiscovery_004 * @tc.desc: 1. set packName not null * set subscribeId is 0 - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1042,15 +1042,15 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_004, testing::ext::TestSize. std::string packName = "com.ohos.test"; // set subscribeInfo is 0 uint16_t subscribeId = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1058,9 +1058,9 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_004, testing::ext::TestSize. * @tc.name: StopDeviceDiscovery_005 * @tc.desc: 1. set packName not null * set subscribeId is 0 - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1071,15 +1071,15 @@ HWTEST_F(DeviceManagerImplTest, StopDeviceDiscovery_005, testing::ext::TestSize. std::string packName = "com.ohos.test"; // set subscribeInfo is 0 uint16_t subscribeId = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::StopDeviceDiscovery with parameter int32_t ret = DeviceManager::GetInstance().StopDeviceDiscovery(packName, subscribeId); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1110,7 +1110,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_001, testing::ext::TestSize.L // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); // 3. check ret is DEVICEMANAGER_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1120,9 +1120,9 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_001, testing::ext::TestSize.L * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1138,15 +1138,15 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_002, testing::ext::TestSize.L std::string extra = ""; // set callback null std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1195,9 +1195,9 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_003, testing::ext::TestSize.L * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1214,15 +1214,15 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_004, testing::ext::TestSize.L std::string extra = ""; // set callback null std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1233,9 +1233,9 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_004, testing::ext::TestSize.L * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1252,15 +1252,15 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice_005, testing::ext::TestSize.L std::string extra = ""; // set callback null std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1285,7 +1285,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_001, testing::ext::TestSize // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceInfo); // 3. check ret is DEVICEMANAGER_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1295,9 +1295,9 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_001, testing::ext::TestSize * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1310,7 +1310,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_002, testing::ext::TestSize // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceInfo); // 3. check ret is DEVICEMANAGER_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1353,9 +1353,9 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_003, testing::ext::TestSize * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1367,12 +1367,15 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_004, testing::ext::TestSize // set dmDeviceInfo null DmDeviceInfo deviceInfo; std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter + int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceId); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceInfo); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); @@ -1386,9 +1389,9 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_004, testing::ext::TestSize * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1400,12 +1403,15 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_005, testing::ext::TestSize // set dmDeviceInfo null DmDeviceInfo deviceInfo; std::shared_ptr callback = nullptr; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter + int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceId); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); int32_t ret= DeviceManager::GetInstance().UnAuthenticateDevice(packName, deviceInfo); // 4. check ret is DM_IPC_SEND_REQUEST_FAILED ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); @@ -1420,7 +1426,7 @@ HWTEST_F(DeviceManagerImplTest, UnAuthenticateDevice_005, testing::ext::TestSize * set extra = null * set callback = nullptr * 2. call DeviceManagerImpl::AuthenticateDevice with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1432,8 +1438,8 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_001, testing::ext::TestSize.Level0) DmAuthParam dmFaParam; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -1443,9 +1449,9 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_001, testing::ext::TestSize.Level0) * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1460,11 +1466,11 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_002, testing::ext::TestSize.Level0) std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); // 4. check ret is DM_OK - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1507,9 +1513,9 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_003, testing::ext::TestSize.Level0) * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1520,15 +1526,15 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_004, testing::ext::TestSize.Level0) std::string packName = "com.ohos.helloworld"; // set dmDeviceInfo null DmAuthParam dmFaParam; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1539,9 +1545,9 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_004, testing::ext::TestSize.Level0) * set dmAppImageInfo null * set extra null * set callback null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::AuthenticateDevice with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1552,15 +1558,15 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_005, testing::ext::TestSize.Level0) std::string packName = "com.ohos.helloworld"; // set dmDeviceInfo null DmAuthParam dmFaParam; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().GetFaParam(packName, dmFaParam); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1569,7 +1575,7 @@ HWTEST_F(DeviceManagerImplTest, GetFaParam_005, testing::ext::TestSize.Level0) * @tc.desc: 1. set packName null * set action null * 2. call DeviceManagerImpl::SetUserOperation with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1582,17 +1588,17 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_001, testing::ext::TestSize.Lev int32_t action = 0; // 2. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: SetUserOperation_002 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1603,15 +1609,15 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_002, testing::ext::TestSize.Lev std::string packName = "com.ohos.test"; // set authParam null int32_t action = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1648,9 +1654,9 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_003, testing::ext::TestSize.Lev * @tc.name: SetUserOperation_004 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1661,15 +1667,15 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_004, testing::ext::TestSize.Lev std::string packName = "com.ohos.test"; // set authParam null int32_t action = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1677,9 +1683,9 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_004, testing::ext::TestSize.Lev * @tc.name: SetUserOperation_005 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1690,15 +1696,15 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_005, testing::ext::TestSize.Lev std::string packName = "com.ohos.test"; // set authParam null int32_t action = 0; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().SetUserOperation(packName, action); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1707,7 +1713,7 @@ HWTEST_F(DeviceManagerImplTest, SetUserOperation_005, testing::ext::TestSize.Lev * @tc.desc: 1. set packName null * set action null * 2. call DeviceManagerImpl::SetUserOperation with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1721,17 +1727,17 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_001, testing::ext::TestSize.L std::string udid = "222"; // 2. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: GetUdidByNetworkId_002 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1743,15 +1749,15 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_002, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string udid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1789,9 +1795,9 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_003, testing::ext::TestSize.L * @tc.name: GetUdidByNetworkId_004 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1803,15 +1809,15 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_004, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string udid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1819,9 +1825,9 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_004, testing::ext::TestSize.L * @tc.name: GetUdidByNetworkId_005 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1833,15 +1839,15 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_005, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string udid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUdidByNetworkId(packName, netWorkId, udid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1850,7 +1856,7 @@ HWTEST_F(DeviceManagerImplTest, GetUdidByNetworkId_005, testing::ext::TestSize.L * @tc.desc: 1. set packName null * set action null * 2. call DeviceManagerImpl::SetUserOperation with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1864,17 +1870,17 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_001, testing::ext::TestSize.L std::string uuid = "222"; // 2. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: GetUuidByNetworkId_002 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_FAILED + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1886,15 +1892,15 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_002, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string uuid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_FAILED + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1932,9 +1938,9 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_003, testing::ext::TestSize.L * @tc.name: GetUuidByNetworkId_004 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1946,15 +1952,15 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_004, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string uuid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_SERVICE_NOT_READY + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1962,9 +1968,9 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_004, testing::ext::TestSize.L * @tc.name: GetUuidByNetworkId_005 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_IPC_SEND_REQUEST_FAILED + * 4. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -1976,15 +1982,15 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_005, testing::ext::TestSize.L // set authParam null std::string netWorkId = "111"; std::string uuid = "222"; - // 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + // 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_POINT_NULL)); + .Times(1).WillOnce(testing::Return(ERR_DM_POINT_NULL)); // 3. call DeviceManagerImpl::SetUserOperation with parameter int32_t ret= DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); - // 4. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 4. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -1992,9 +1998,9 @@ HWTEST_F(DeviceManagerImplTest, GetUuidByNetworkId_005, testing::ext::TestSize.L * @tc.name: RegisterDeviceManagerFaCallback_001 * @tc.desc: 1. set packName not null * set action null - * 2. MOCK IpcClientProxy SendRequest return DM_POINT_NULL + * 2. MOCK IpcClientProxy SendRequest return ERR_DM_POINT_NULL * 3. call DeviceManagerImpl::SetUserOperation with parameter - * 4. check ret is DM_INVALID_VALUE + * 4. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2007,8 +2013,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_001, testing::ex std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packName, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2038,7 +2044,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_002, testing::ex * @tc.desc: 1. set packName not null * set callback not null * 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2051,8 +2057,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_003, testing::ex std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packName, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2060,7 +2066,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_003, testing::ex * @tc.desc: 1. set packName not null * set callback not null * 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2073,8 +2079,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_004, testing::ex std::shared_ptr callback = std::make_shared(); // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packName, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2082,7 +2088,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_004, testing::ex * @tc.desc: 1. set packName not null * set callback not null * 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2095,15 +2101,15 @@ HWTEST_F(DeviceManagerImplTest, RegisterDeviceManagerFaCallback_005, testing::ex std::shared_ptr callback = nullptr; // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packName, callback); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDeviceManagerFaCallback_001 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDeviceManagerFaCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2114,8 +2120,8 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDeviceManagerFaCallback_001, testing:: std::string packName = ""; // 2. call DeviceManagerImpl::RegisterDeviceManagerFaCallback with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDeviceManagerFaCallback(packName); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2257,7 +2263,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDeviceManagerFaCallback_005, testing:: * set extra null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2270,8 +2276,8 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_006, testing::ext::Test std::string extra= "test"; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(pkgName, extra); - // 3. check ret is DM_INVALID_VALUE; - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY; + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2280,7 +2286,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_006, testing::ext::Test * set extra null * set callback not null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2294,7 +2300,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_007, testing::ext::Test // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra); // 3. check ret is DM_OK - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2303,7 +2309,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_007, testing::ext::Test * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2317,11 +2323,11 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_008, testing::ext::Test std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2331,7 +2337,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_008, testing::ext::Test * set extra not null * set callback not null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2345,11 +2351,11 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_009, testing::ext::Test std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().RegisterDevStateCallback(packName, extra); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2385,7 +2391,7 @@ HWTEST_F(DeviceManagerImplTest, RegisterDevStateCallback_010, testing::ext::Test * @tc.name: UnRegisterDevStateCallback_006 * @tc.desc: 1. set packName null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2398,15 +2404,15 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_006, testing::ext::Te std::string extra= ""; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnRegisterDevStateCallback_007 * @tc.desc: 1. set packName not null * 2. call DeviceManagerImpl::UnRegisterDevStateCallback with parameter - * 3. check ret is DM_INVALID_VALUE + * 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2419,8 +2425,8 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_007, testing::ext::Te std::string extra= "test"; // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -2429,7 +2435,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_007, testing::ext::Te * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2443,11 +2449,11 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_008, testing::ext::Te std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -2457,7 +2463,7 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_008, testing::ext::Te * set extra not null * set callback null * 2. call DeviceManagerImpl::RegisterDevStateCallback with parameter - * 3. check ret is DM_IPC_SEND_REQUEST_FAILED + * 3. check ret is ERR_DM_IPC_SEND_REQUEST * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK @@ -2471,11 +2477,11 @@ HWTEST_F(DeviceManagerImplTest, UnRegisterDevStateCallback_009, testing::ext::Te std::shared_ptr mockInstance = std::make_shared(); DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 2. call DeviceManagerImpl::AuthenticateDevice with parameter int32_t ret= DeviceManager::GetInstance().UnRegisterDevStateCallback(packName, extra); - // 3. check ret is DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_IPC_SEND_REQUEST_FAILED); + // 3. check ret is ERR_DM_IPC_SEND_REQUEST + ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index b684f95463b1a79b59d82cd54f287eb2f09c558e..9a00a986a7825f01d9c37cda0203fc8417467081 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -42,7 +42,7 @@ void DeviceManagerServiceTest::TearDownTestCase() namespace { /** * @tc.name: StartDeviceDiscovery_001 - * @tc.desc: Set StartDeviceDiscovery's flag bit intFlag_ to False and return DM_NOT_INIT + * @tc.desc: Set StartDeviceDiscovery's flag bit intFlag_ to False and return ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -53,12 +53,12 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_001, testing::ext::TestS DmSubscribeInfo subscribeInfo; std::string extra = "test"; int ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: StartDeviceDiscovery_002 - * @tc.desc: Empty pkgName of StartDeviceDiscovery and return DM_INPUT_PARA_EMPTY + * @tc.desc: Empty pkgName of StartDeviceDiscovery and return ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -69,13 +69,13 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_002, testing::ext::TestS std::string extra = "test"; DeviceManagerService::GetInstance().Init(); int ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: StartDeviceDiscovery_003 * @tc.desc: Call StartDeviceDiscovery twice with pkgName not null and flag bit not false and return - * DM_DISCOVERY_REPEATED + * ERR_DM_DISCOVERY_REPEATED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -87,12 +87,12 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_003, testing::ext::TestS int ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); pkgName = "1com.ohos.test1"; ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ(ret, DM_DISCOVERY_FAILED); + EXPECT_EQ(ret, ERR_DM_DISCOVERY); } /** * @tc.name: StopDeviceDiscovery_001 - * @tc.desc: Set StopDeviceDiscovery's flag bit intFlag_ to false and return DM_NOT_INIT + * @tc.desc: Set StopDeviceDiscovery's flag bit intFlag_ to false and return ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -102,12 +102,12 @@ HWTEST_F(DeviceManagerServiceTest, StopDeviceDiscovery_001, testing::ext::TestSi std::string pkgName = "com.ohos.test"; uint16_t subscribeId = 1; int ret = DeviceManagerService::GetInstance().StopDeviceDiscovery(pkgName, subscribeId); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name:StopDeviceDiscovery_002 - * @tc.desc: StopDeviceDiscovery is initialized, pkgName is null, and its return value is DM_INPUT_PARA_EMPTY + * @tc.desc: StopDeviceDiscovery is initialized, pkgName is null, and its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -117,12 +117,12 @@ HWTEST_F(DeviceManagerServiceTest, StopDeviceDiscovery_002, testing::ext::TestSi uint16_t subscribeId = 1; DeviceManagerService::GetInstance().Init(); int ret = DeviceManagerService::GetInstance().StopDeviceDiscovery(pkgName, subscribeId); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: GetLocalDeviceInfo_001 - * @tc.desc: Set the flag bit of GetLocalDeviceInfo to intFlag_ to false; The return value is DM_NOT_INIT + * @tc.desc: Set the flag bit of GetLocalDeviceInfo to intFlag_ to false; The return value is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -131,7 +131,7 @@ HWTEST_F(DeviceManagerServiceTest, GetLocalDeviceInfo_001, testing::ext::TestSiz DeviceManagerService::GetInstance().intFlag_ = false; DmDeviceInfo info; int ret = DeviceManagerService::GetInstance().GetLocalDeviceInfo(info); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -150,7 +150,7 @@ HWTEST_F(DeviceManagerServiceTest, GetLocalDeviceInfo_002, testing::ext::TestSiz /** * @tc.name: Init_001 - * @tc.desc: The OnDeviceFound function does the worong case and return DM_INT_MULTIPLE + * @tc.desc: The OnDeviceFound function does the worong case and return ERR_DM_INIT_REPEATED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -158,7 +158,7 @@ HWTEST_F(DeviceManagerServiceTest, Init_001, testing::ext::TestSize.Level0) { DeviceManagerService::GetInstance().intFlag_ = true; int ret = DeviceManagerService::GetInstance().Init(); - EXPECT_EQ(ret, DM_INT_MULTIPLE); + EXPECT_EQ(ret, ERR_DM_INIT_REPEATED); } /** @@ -177,7 +177,7 @@ HWTEST_F(DeviceManagerServiceTest, Init_002, testing::ext::TestSize.Level0) /** * @tc.name: GetTrustedDeviceList_001 - * @tc.desc: Set the intFlag of GetTrustedDeviceList to false. The return value is DM_NOT_INIT + * @tc.desc: Set the intFlag of GetTrustedDeviceList to false. The return value is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -189,12 +189,12 @@ HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_001, testing::ext::TestS std::string extra = "jdddd"; std::vector deviceList; int ret = DeviceManagerService::GetInstance().GetTrustedDeviceList(pkgName, extra, deviceList); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: GetTrustedDeviceList_002 - * @tc.desc:Set the intFlag of GetTrustedDeviceList to true and pkgName = null; The return value is DM_INPUT_PARA_EMPTY + * @tc.desc:Set the intFlag of GetTrustedDeviceList to true and pkgName = null; The return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -205,12 +205,12 @@ HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_002, testing::ext::TestS std::string extra = "jdddd"; std::vector deviceList; int ret = DeviceManagerService::GetInstance().GetTrustedDeviceList(pkgName, extra, deviceList); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: AuthenticateDevice_001 - * @tc.desc: 将GAuthenticateDevice的intFlag设置为false,设置pkgName = "com.ohos.test";其返回值为DM_NOT_INIT + * @tc.desc: 将GAuthenticateDevice的intFlag设置为false,设置pkgName = "com.ohos.test";其返回值为ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -222,12 +222,12 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_001, testing::ext::TestSiz int32_t authType = 0; std::string deviceId = "2345"; int ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: AuthenticateDevice_002 - * @tc.desc: Set intFlag for GAuthenticateDevice to True and pkgName to null; The return value is DM_INPUT_PARA_EMPTY + * @tc.desc: Set intFlag for GAuthenticateDevice to True and pkgName to null; The return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -239,12 +239,12 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_002, testing::ext::TestSiz int32_t authType = 0; std::string deviceId = " 2345"; int ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: AuthenticateDevice_003 - * @tc.desc: Set intFlag for GAuthenticateDevice to True and deviceId to null; The return value is DM_INPUT_PARA_EMPTY + * @tc.desc: Set intFlag for GAuthenticateDevice to True and deviceId to null; The return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -256,7 +256,7 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_003, testing::ext::TestSiz int32_t authType = 0; std::string deviceId; int ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: AuthenticateDevice_004 @@ -272,12 +272,12 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_004, testing::ext::TestSiz int32_t authType = 0; std::string deviceId = "123456"; int ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra); - EXPECT_EQ(ret, DM_AUTH_NOT_SUPPORT); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: UnAuthenticateDevice_001 - * @tc.desc: 将UnAuthenticateDevice的intFlag设置为false,设置pkgName = "com.ohos.test";其返回值为DM_NOT_INIT + * @tc.desc: 将UnAuthenticateDevice的intFlag设置为false,设置pkgName = "com.ohos.test";其返回值为ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -287,12 +287,12 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_001, testing::ext::TestS std::string pkgName = "com.ohos.test"; std::string deviceId = "12345"; int ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: UnAuthenticateDevice_002 - * @tc.desc: Set intFlag for UnAuthenticateDevice to True and pkgName to null; The return value is DM_INPUT_PARA_EMPTY + * @tc.desc: Set intFlag for UnAuthenticateDevice to True and pkgName to null; The return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -302,13 +302,13 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_002, testing::ext::TestS std::string pkgName; std::string deviceId = "12345"; int ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: UnAuthenticateDevice_003 * @tc.desc: Set intFlag for UnAuthenticateDevice to true and pkgName to com.ohos.test; set deviceId null ,The return - * value is DM_INPUT_PARA_EMPTY + * value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -318,13 +318,13 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_003, testing::ext::TestS std::string pkgName = "com.ohos.test"; std::string deviceId; int ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** * @tc.name: VerifyAuthentication_001 * @tc.desc: Set intFlag for VerifyAuthentication to false and set authParam = "jdjjjj",The return value is - * DM_NOT_INIT + * ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -333,7 +333,7 @@ HWTEST_F(DeviceManagerServiceTest, VerifyAuthentication_001, testing::ext::TestS DeviceManagerService::GetInstance().intFlag_ = false; std::string authParam = "jdjjjj"; int ret = DeviceManagerService::GetInstance().VerifyAuthentication(authParam); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** @@ -356,7 +356,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_001, testing::ext::TestSiz /** * @tc.name: GetUdidByNetworkId_002 * @tc.desc: Make not init for GetUdidByNetworkId,The return value is - * DM_NOT_INIT + * ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -367,13 +367,13 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_002, testing::ext::TestSiz std::string netWorkId = ""; std::string udid = ""; int ret = DeviceManagerService::GetInstance().GetUdidByNetworkId(pkgName, netWorkId, udid); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: GetUdidByNetworkId_003 * @tc.desc: Make pkgName empty for GetUdidByNetworkId,The return value is - * DM_INPUT_PARA_EMPTY + * ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -384,7 +384,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_003, testing::ext::TestSiz std::string netWorkId = ""; std::string udid = ""; int ret = DeviceManagerService::GetInstance().GetUdidByNetworkId(pkgName, netWorkId, udid); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -407,7 +407,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_001, testing::ext::TestSiz /** * @tc.name: GetUuidByNetworkId_002 * @tc.desc: Make not init for GetUuidByNetworkId,The return value is - * DM_NOT_INIT + * ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -418,13 +418,13 @@ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_002, testing::ext::TestSiz std::string netWorkId = ""; std::string uuid = ""; int ret = DeviceManagerService::GetInstance().GetUuidByNetworkId(pkgName, netWorkId, uuid); - EXPECT_EQ(ret, DM_NOT_INIT); + EXPECT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: GetUuidByNetworkId_003 * @tc.desc: Make pkgName empty for GetUuidByNetworkId,The return value is - * DM_INPUT_PARA_EMPTY + * ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -435,7 +435,7 @@ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_003, testing::ext::TestSiz std::string netWorkId = ""; std::string uuid = ""; int ret = DeviceManagerService::GetInstance().GetUuidByNetworkId(pkgName, netWorkId, uuid); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -456,7 +456,7 @@ HWTEST_F(DeviceManagerServiceTest, GetFaParam_001, testing::ext::TestSize.Level0 /** * @tc.name: GetFaParam_002 * @tc.desc: Make pkgName empty for GetFaParam, The return value is - * DM_INPUT_PARA_EMPTY + * ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -465,7 +465,7 @@ HWTEST_F(DeviceManagerServiceTest, GetFaParam_002, testing::ext::TestSize.Level0 std::string pkgName = ""; DmAuthParam authParam; int ret = DeviceManagerService::GetInstance().GetFaParam(pkgName, authParam); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -486,7 +486,7 @@ HWTEST_F(DeviceManagerServiceTest, SetUserOperation_001, testing::ext::TestSize. /** * @tc.name: SetUserOperation_002 * @tc.desc: Make pkgName empty for SetUserOperation,The return value is - * DM_INPUT_PARA_EMPTY + * ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -495,7 +495,7 @@ HWTEST_F(DeviceManagerServiceTest, SetUserOperation_002, testing::ext::TestSize. std::string pkgName = ""; int32_t action = 0; int ret = DeviceManagerService::GetInstance().SetUserOperation(pkgName, action); - EXPECT_EQ(ret, DM_INPUT_PARA_EMPTY); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** diff --git a/test/unittest/UTTest_device_profile_adapter.cpp b/test/unittest/UTTest_device_profile_adapter.cpp index 7147b4d42031d5e138a8b66d8ffaac49f04ebd9e..c07d386851cc48c5bcac18ea9b5fc0d4820d188d 100644 --- a/test/unittest/UTTest_device_profile_adapter.cpp +++ b/test/unittest/UTTest_device_profile_adapter.cpp @@ -48,7 +48,7 @@ std::shared_ptr deviceStateMgr = std::make_sharedUnAuthenticateDevice(pkgName, deviceId); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::HandleAuthenticateTimeout_001 - * @tc.desc: authResponseContext_= nullptr; Call handleauthenticatemeout to check whether the return value is DM_FAILED + * @tc.desc: authResponseContext_= nullptr; Call handleauthenticatemeout to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -121,7 +121,7 @@ HWTEST_F(DmAuthManagerTest, EstablishAuthChannel_001, testing::ext::TestSize.Lev /** * @tc.name: DmAuthManager::StartAuthProcess_001 - * @tc.desc: Whether the return value of calling startauthprocess is DM_FAILED + * @tc.desc: Whether the return value of calling startauthprocess is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -211,7 +211,7 @@ HWTEST_F(DmAuthManagerTest, AddMember_001, testing::ext::TestSize.Level0) authManager->hiChainConnector_->RegisterHiChainCallback(authManager); authManager->SetAuthResponseState(authResponseState); int32_t ret = authManager->AddMember(deviceId); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -264,7 +264,7 @@ HWTEST_F(DmAuthManagerTest, GetPinCode_001, testing::ext::TestSize.Level0) std::make_shared(softbusConnector, listener, hiChainConnector_); authManager->authResponseContext_ = std::make_shared(); int32_t ret = authManager->GetPinCode(); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_dm_device_info_manager.cpp b/test/unittest/UTTest_dm_device_info_manager.cpp index 595a0590354d213a90e633ec6818816bd4257226..768c081ec5d51f671978f34c9d65223b130767c8 100644 --- a/test/unittest/UTTest_dm_device_info_manager.cpp +++ b/test/unittest/UTTest_dm_device_info_manager.cpp @@ -45,7 +45,7 @@ std::shared_ptr dmDeviceStateManager = std::make_sharedStartDeviceDiscovery(pkgName, subscribeInfo, extra); int32_t ret = discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ(ret, DM_DISCOVERY_REPEATED); + EXPECT_EQ(ret, ERR_DM_DISCOVERY_REPEATED); } /** * @tc.name:StartDeviceDiscovery_002 * @tc.desc: pkgame changed, call StartDeviceDiscovery twice - * so that its discoveryQueue is not empty and return DM_DISCOVERY_REPEATED + * so that its discoveryQueue is not empty and return ERR_DM_DISCOVERY_REPEATED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -105,7 +105,7 @@ HWTEST_F(DmDiscoveryManagerTest, StartDeviceDiscovery_002, testing::ext::TestSiz discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); pkgName = "com.ohos.helloworld.new"; int32_t ret = discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); - ASSERT_EQ(ret, DM_DISCOVERY_FAILED); + ASSERT_EQ(ret, ERR_DM_DISCOVERY); } /** diff --git a/test/unittest/UTTest_hichain_connector.cpp b/test/unittest/UTTest_hichain_connector.cpp index 13e041125a6b4e08265439be09bad1c5c3f48602..cc48b244a56caa056611bc7298f56872caea650c 100644 --- a/test/unittest/UTTest_hichain_connector.cpp +++ b/test/unittest/UTTest_hichain_connector.cpp @@ -49,7 +49,7 @@ std::shared_ptr discoveryMgr = /** * @tc.name: CreateGroup_001 - * @tc.desc: Set the deviceGroupManager_ pointer to CreateGroup to NULlptr and return DM_INVALID_VALUE + * @tc.desc: Set the deviceGroupManager_ pointer to CreateGroup to NULlptr and return ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -59,7 +59,7 @@ HWTEST_F(HichainConnectorTest, CreateGroup_001, testing::ext::TestSize.Level0) std::string groupName = "dfggg"; hiChainConnector->deviceGroupManager_ = nullptr; int ret = hiChainConnector->CreateGroup(requestId, groupName); - EXPECT_EQ(ret, DM_INVALID_VALUE); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -73,7 +73,7 @@ HWTEST_F(HichainConnectorTest, CreateGroup_002, testing::ext::TestSize.Level0) int64_t requestId = 123456; std::string groupName = "uuiioo"; int ret = hiChainConnector->CreateGroup(requestId, groupName); - EXPECT_EQ(ret, DM_INVALID_VALUE); + EXPECT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -254,7 +254,7 @@ HWTEST_F(HichainConnectorTest, AddMember_002, testing::ext::TestSize.Level0) std::string connectInfo; std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->AddMember(deviceId, connectInfo); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** @@ -336,7 +336,7 @@ HWTEST_F(HichainConnectorTest, DeleteGroup_001, testing::ext::TestSize.Level0) /** * @tc.name: GetRelatedGroups_001 - * @tc.desc: set DeviceId 123 groupList null and return DM_FAILED + * @tc.desc: set DeviceId 123 groupList null and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -346,12 +346,12 @@ HWTEST_F(HichainConnectorTest, GetRelatedGroups_001, testing::ext::TestSize.Leve std::vector groupList; std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetRelatedGroups(DeviceId, groupList); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: GetRelatedGroups_002 - * @tc.desc: set DeviceId = 12345,groupList null and return DM_FAILED + * @tc.desc: set DeviceId = 12345,groupList null and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -361,7 +361,7 @@ HWTEST_F(HichainConnectorTest, GetRelatedGroups_002, testing::ext::TestSize.Leve std::vector groupList; std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetRelatedGroups(DeviceId, groupList); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** @@ -381,7 +381,7 @@ HWTEST_F(HichainConnectorTest, SyncGroups_001, testing::ext::TestSize.Level0) /** * @tc.name: GetSyncGroupList_001 - * @tc.desc: set groupList null,and return DM_FAILED + * @tc.desc: set groupList null,and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -391,7 +391,7 @@ HWTEST_F(HichainConnectorTest, GetSyncGroupList_001, testing::ext::TestSize.Leve std::vector syncGroupList; std::shared_ptr hichainConnector = std::make_shared(); int ret = hichainConnector->GetSyncGroupList(groupList, syncGroupList); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_ipc_client_manager.cpp b/test/unittest/UTTest_ipc_client_manager.cpp index a7d99cc0dd4b9941692e715de25d5c937d79de76..a8eb8ea1445960fe3554fa25acccf95bd822f5b6 100644 --- a/test/unittest/UTTest_ipc_client_manager.cpp +++ b/test/unittest/UTTest_ipc_client_manager.cpp @@ -81,7 +81,7 @@ HWTEST_F(IpcClientManagerTest, OnRemoteDied_001, testing::ext::TestSize.Level0) * @tc.desc: 1. new a dmInterface * 2. set IpcClientManager dmInterface_ not null * 3. call ClientInit - * 4. check ret is not DM_FAILED + * 4. check ret is not ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -96,8 +96,8 @@ HWTEST_F(IpcClientManagerTest, ClientInit_001, testing::ext::TestSize.Level0) instance->dmInterface_ = dmInterface; // 3. call ClientInit int ret = instance->ClientInit(); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -105,7 +105,7 @@ HWTEST_F(IpcClientManagerTest, ClientInit_001, testing::ext::TestSize.Level0) * @tc.desc: 1. new a dmInterface * 2. set IpcClientManager dmInterface_ not null * 3. call ClientInit - * 4. check ret is not DM_FAILED + * 4. check ret is not ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -114,8 +114,8 @@ HWTEST_F(IpcClientManagerTest, ClientInit_002, testing::ext::TestSize.Level0) std::shared_ptr instance = std::make_shared(); // 3. call ClientInit int ret = instance->ClientInit(); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -124,7 +124,7 @@ HWTEST_F(IpcClientManagerTest, ClientInit_002, testing::ext::TestSize.Level0) * 2. set a pkgName not null * 3. add listener and pkgName in dmListener_ Map * 4. call Init with pkgName - * 5. check ret is not DM_FAILED + * 5. check ret is not ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -139,16 +139,16 @@ HWTEST_F(IpcClientManagerTest, Init_001, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 4. call Init with pkgName int32_t ret = instance->Init(pkgName); - // 5. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 5. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** * @tc.name: Init_002 * @tc.desc: 1. set pkcName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED * 3. call Init with pkgName - * 4. check ret is DM_FAILED + * 4. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -156,17 +156,17 @@ HWTEST_F(IpcClientManagerTest, Init_002, testing::ext::TestSize.Level0) { // 1. set pkcName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call Init with pkgName int32_t ret = instance->Init(pkgName); - // 4. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 4. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -214,7 +214,7 @@ HWTEST_F(IpcClientManagerTest, Init_004, testing::ext::TestSize.Level0) std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call Init with pkgName int32_t ret = instance->Init(pkgName); // 4. check ret is DEVICEMANAGER_OK @@ -224,9 +224,9 @@ HWTEST_F(IpcClientManagerTest, Init_004, testing::ext::TestSize.Level0) /** * @tc.name: Init_005 * @tc.desc: 1. set pkcName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC * 3. call Init with pkgName - * 4. check ret is DM_IPC_FAILED + * 4. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -240,11 +240,11 @@ HWTEST_F(IpcClientManagerTest, Init_005, testing::ext::TestSize.Level0) std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 3. call Init with pkgName int32_t ret = instance->Init(pkgName); - // 4. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 4. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -265,18 +265,18 @@ HWTEST_F(IpcClientManagerTest, UnInit1, testing::ext::TestSize.Level0) instance->dmInterface_ = nullptr; // 2. call UnInit with pkgName int32_t ret = instance->UnInit(pkgName); - // 3. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 3. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: UnInit_002 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call UnInit with pkgName - * 6. check ret is DM_FAILED + * 6. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -284,11 +284,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. set IpcClientManager dmInterface_ not null std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; @@ -297,8 +297,8 @@ HWTEST_F(IpcClientManagerTest, UnInit_002, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call UnInit with pkgName int32_t ret = instance->UnInit(pkgName); - // 6. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 6. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -336,11 +336,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_003, testing::ext::TestSize.Level0) /** * @tc.name: UnInit_004 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_SERVICE_NOT_READY + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_NOT_INIT * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call UnInit with pkgName - * 6. check ret is DM_SERVICE_NOT_READY + * 6. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -348,11 +348,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return DM_SERVICE_NOT_READY + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_NOT_INIT sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. set IpcClientManager dmInterface_ not null std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; @@ -361,18 +361,18 @@ HWTEST_F(IpcClientManagerTest, UnInit_004, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call UnInit with pkgName int32_t ret = instance->UnInit(pkgName); - // 6. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 6. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: UnInit_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call UnInit with pkgName - * 6. check ret is DM_IPC_FAILED + * 6. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -380,11 +380,11 @@ HWTEST_F(IpcClientManagerTest, UnInit_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 3. set IpcClientManager dmInterface_ not null std::shared_ptr instance = std::make_shared(); instance->dmInterface_ = mockInstance; @@ -393,8 +393,8 @@ HWTEST_F(IpcClientManagerTest, UnInit_005, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call UnInit with pkgName int32_t ret = instance->UnInit(pkgName); - // 6. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 6. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -402,7 +402,7 @@ HWTEST_F(IpcClientManagerTest, UnInit_005, testing::ext::TestSize.Level0) * @tc.desc: 1. set pkgName null * 2. set IpcClientManager dmInterface_null * 3. call SendRequest with parameter - * 4. check ret is DM_SERVICE_NOT_READY + * 4. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -418,18 +418,18 @@ HWTEST_F(IpcClientManagerTest, SendRequest_001, testing::ext::TestSize.Level0) instance->dmInterface_ = nullptr; // 3. call SendRequest with parameter int ret = instance->SendRequest(0, req, rsp); - // 4. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 4. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: SendRequest_002 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call SendRequest with parameter - * 6. check ret is DM_FAILED + * 6. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -440,11 +440,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_002, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return DM_FAILED + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); std::shared_ptr instance = std::make_shared(); // 3. set IpcClientManager dmInterface_ not null instance->dmInterface_ = mockInstance; @@ -453,8 +453,8 @@ HWTEST_F(IpcClientManagerTest, SendRequest_002, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call SendRequest with parameter int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 6. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -495,11 +495,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_003, testing::ext::TestSize.Level0) /** * @tc.name: SendRequest_004 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_SERVICE_NOT_READY + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_NOT_INIT * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call SendRequest with parameter - * 6. check ret is DM_SERVICE_NOT_READY + * 6. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -510,11 +510,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_004, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return DM_SERVICE_NOT_READY + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_NOT_INIT sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + .Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); std::shared_ptr instance = std::make_shared(); // 3. set IpcClientManager dmInterface_ not null instance->dmInterface_ = mockInstance; @@ -523,18 +523,18 @@ HWTEST_F(IpcClientManagerTest, SendRequest_004, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call SendRequest with parameter int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 6. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: SendRequest_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC * 3. set IpcClientManager dmInterface_ not null * 4. set IpcClientManager dmListener_ not null * 5. call SendRequest with parameter - * 6. check ret is DM_IPC_FAILED + * 6. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -545,11 +545,11 @@ HWTEST_F(IpcClientManagerTest, SendRequest_005, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return DM_IPC_FAILED + // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC sptr remoteObject = nullptr; auto mockInstance = new MockIpcClientManager(remoteObject); EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_IPC)); std::shared_ptr instance = std::make_shared(); // 3. set IpcClientManager dmInterface_ not null instance->dmInterface_ = mockInstance; @@ -558,8 +558,8 @@ HWTEST_F(IpcClientManagerTest, SendRequest_005, testing::ext::TestSize.Level0) instance->dmListener_[pkgName] = listener; // 5. call SendRequest with parameter int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 6. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** diff --git a/test/unittest/UTTest_ipc_client_proxy.cpp b/test/unittest/UTTest_ipc_client_proxy.cpp index 46cb27eeb26fe6c781a724c8abc3e419245473c6..f9e53aa76d518925d66e77902dbee5c3a4c20ee3 100644 --- a/test/unittest/UTTest_ipc_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_client_proxy.cpp @@ -48,7 +48,7 @@ namespace { * @tc.desc: 1. set pkgName not null * 2. set IpcClientProxy ipcClientManager nullptr * 3. call IpcClientProxy Init - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -61,16 +61,16 @@ HWTEST_F(IpcClientProxyTest, Init_001, testing::ext::TestSize.Level0) std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); // 3. call IpcClientProxy int32_t ret = ipcClientProxy->Init(pkgName); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** * @tc.name: Init_002 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient Init return DM_FAILED + * 2. Mock IpcClient Init return ERR_DM_FAILED * 3. call IpcClientProxy Init - * 4. check ret is DM_FAILED + * 4. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -78,15 +78,15 @@ HWTEST_F(IpcClientProxyTest, Init_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_FAILED + // 2. Mock IpcClient Init return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_FAILED)); + EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->Init(pkgName); - // 4. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 4. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -116,9 +116,9 @@ HWTEST_F(IpcClientProxyTest, Init_003, testing::ext::TestSize.Level0) /** * @tc.name: Init_004 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient Init return DM_SERVICE_NOT_READY + * 2. Mock IpcClient Init return ERR_DM_NOT_INIT * 3. call IpcClientProxy Init - * 4. check ret is DM_SERVICE_NOT_READY + * 4. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -126,23 +126,23 @@ HWTEST_F(IpcClientProxyTest, Init_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_SERVICE_NOT_READY + // 2. Mock IpcClient Init return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->Init(pkgName); - // 4. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 4. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: Init_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient Init return DM_IPC_FAILED + * 2. Mock IpcClient Init return ERR_DM_IPC * 3. call IpcClientProxy Init - * 4. check ret is DM_IPC_FAILED + * 4. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -150,15 +150,15 @@ HWTEST_F(IpcClientProxyTest, Init_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_IPC_FAILED + // 2. Mock IpcClient Init return ERR_DM_IPC std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + EXPECT_CALL(*mockInstance, Init(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->Init(pkgName); - // 4. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 4. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -166,7 +166,7 @@ HWTEST_F(IpcClientProxyTest, Init_005, testing::ext::TestSize.Level0) * @tc.desc: 1. set pkgName not null * 2. set IpcClientProxy ipcClientManager nullptr * 3. call IpcClientProxy UnInit - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -179,16 +179,16 @@ HWTEST_F(IpcClientProxyTest, UnInit_001, testing::ext::TestSize.Level0) std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); // 3. call IpcClientProxy int32_t ret = ipcClientProxy->UnInit(pkgName); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** * @tc.name: UnInit_002 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient Init return DM_FAILED + * 2. Mock IpcClient Init return ERR_DM_FAILED * 3. call IpcClientProxy UnInit - * 4. check ret is DM_FAILED + * 4. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -196,15 +196,15 @@ HWTEST_F(IpcClientProxyTest, UnInit_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_FAILED + // 2. Mock IpcClient Init return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->UnInit(pkgName); - // 4. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 4. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -234,9 +234,9 @@ HWTEST_F(IpcClientProxyTest, UnInit_003, testing::ext::TestSize.Level0) /** * @tc.name: UnInit_004 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient UnInit return DM_SERVICE_NOT_READY + * 2. Mock IpcClient UnInit return ERR_DM_NOT_INIT * 3. call IpcClientProxy UnInit - * 4. check ret is DM_SERVICE_NOT_READY + * 4. check ret is ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -244,23 +244,23 @@ HWTEST_F(IpcClientProxyTest, UnInit_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_SERVICE_NOT_READY + // 2. Mock IpcClient Init return ERR_DM_NOT_INIT std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_SERVICE_NOT_READY)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_NOT_INIT)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->UnInit(pkgName); - // 4. check ret is DM_SERVICE_NOT_READY - ASSERT_EQ(ret, DM_SERVICE_NOT_READY); + // 4. check ret is ERR_DM_NOT_INIT + ASSERT_EQ(ret, ERR_DM_NOT_INIT); } /** * @tc.name: UnInit_005 * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClient UnInit return DM_IPC_FAILED + * 2. Mock IpcClient UnInit return ERR_DM_IPC * 3. call IpcClientProxy UnInit - * 4. check ret is DM_IPC_FAILED + * 4. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -268,15 +268,15 @@ HWTEST_F(IpcClientProxyTest, UnInit_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClient Init return DM_IPC_FAILED + // 2. Mock IpcClient Init return ERR_DM_IPC std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; - EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(DM_IPC_FAILED)); + EXPECT_CALL(*mockInstance, UnInit(testing::_)).Times(1).WillOnce(testing::Return(ERR_DM_IPC)); // 3. call IpcClientProxy Init std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->UnInit(pkgName); - // 4. check ret is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 4. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -301,7 +301,7 @@ HWTEST_F(IpcClientProxyTest, SendRequest_001, testing::ext::TestSize.Level0) std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->SendRequest(0, req, rsp); // 3. check ret is DEVICEMANAGER_NULLPTR - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -310,7 +310,7 @@ HWTEST_F(IpcClientProxyTest, SendRequest_001, testing::ext::TestSize.Level0) * set rsp nullptr * set IpcClientProxy ipcClientManager not null * 2. call IpcClientProxy SendRequest - * 3. check ret is DM_POINT_NULL + * 3. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -325,8 +325,8 @@ HWTEST_F(IpcClientProxyTest, SendRequest_002, testing::ext::TestSize.Level0) // 2. call IpcClientProxy SendRequest std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->SendRequest(0, req, rsp); - // 3. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 3. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -335,7 +335,7 @@ HWTEST_F(IpcClientProxyTest, SendRequest_002, testing::ext::TestSize.Level0) * set rsp not nullptr * set IpcClientProxy ipcClientManager null * 2. call IpcClientProxy SendRequest - * 3. check ret is DM_POINT_NULL + * 3. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -350,17 +350,17 @@ HWTEST_F(IpcClientProxyTest, SendRequest_003, testing::ext::TestSize.Level0) // 2. call IpcClientProxy SendRequest std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->SendRequest(0, req, rsp); - // 3. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 3. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** * @tc.name: SendRequest_004 * @tc.desc: 1. set req not nullptr * set rsp not nullptr - * 2. Mock IpcClient SendRequest return DM_FAILED + * 2. Mock IpcClient SendRequest return ERR_DM_FAILED * 3. call IpcClientProxy SendRequest - * 4. check ret is DM_FAILED + * 4. check ret is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -370,16 +370,16 @@ HWTEST_F(IpcClientProxyTest, SendRequest_004, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); // set rsp not nullptr std::shared_ptr rsp = std::make_shared(); - // 2. Mock IpcClient SendRequest return DM_FAILED + // 2. Mock IpcClient SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_FAILED)); + .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); // 3. call IpcClientProxy SendRequest std::shared_ptr ipcClientProxy = std::make_shared(ipcClientManager); int32_t ret = ipcClientProxy->SendRequest(0, req, rsp); - // 4. check ret is DM_FAILED - ASSERT_EQ(ret, DM_FAILED); + // 4. check ret is ERR_DM_FAILED + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -398,7 +398,7 @@ HWTEST_F(IpcClientProxyTest, SendRequest5, testing::ext::TestSize.Level0) std::shared_ptr req = std::make_shared(); // set rsp not nullptr std::shared_ptr rsp = std::make_shared(); - // 2. Mock IpcClient SendRequest return DM_FAILED + // 2. Mock IpcClient SendRequest return ERR_DM_FAILED std::shared_ptr mockInstance = std::make_shared(); std::shared_ptr ipcClientManager = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) diff --git a/test/unittest/UTTest_ipc_client_server_proxy.cpp b/test/unittest/UTTest_ipc_client_server_proxy.cpp index 941eb7790a12f51c565a67a824fc35dea0207f44..a1b6886005f18c2838bcc5dce62f17ed6a52ebdb 100644 --- a/test/unittest/UTTest_ipc_client_server_proxy.cpp +++ b/test/unittest/UTTest_ipc_client_server_proxy.cpp @@ -63,7 +63,7 @@ HWTEST_F(IpcClientServerProxyTest, SendCmd_001, testing::ext::TestSize.Level0) auto instance = new IpcClientServerProxy(remoteObject); int ret = instance->SendCmd(cmdCode, nullptr, nullptr); // 4. check ret is DEVICEMANAGER_NULLPTR - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_ipc_client_stub.cpp b/test/unittest/UTTest_ipc_client_stub.cpp index 8e280555192b8a4a7192ba954b63a48006a227bc..f08dcacd75bba8d4fe21e827c7bc63d1f210ab4c 100644 --- a/test/unittest/UTTest_ipc_client_stub.cpp +++ b/test/unittest/UTTest_ipc_client_stub.cpp @@ -56,7 +56,7 @@ namespace { * set MessageParcel not null * 2. set set code is 999 * 3. call IpcClientStub OnRemoteRequest with parameter - * 4. check result is DM_FAILED + * 4. check result is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -74,10 +74,10 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_001, testing::ext::TestSize.Level0) // 3. call IpcClientStub OnRemoteRequest with parameter int32_t result = instance->OnRemoteRequest(code, data, reply, option); if (result != DM_OK) { - result = DM_FAILED; + result = ERR_DM_FAILED; } - // 4. check result is DM_FAILED - ASSERT_EQ(result, DM_FAILED); + // 4. check result is ERR_DM_FAILED + ASSERT_EQ(result, ERR_DM_FAILED); } /** @@ -114,7 +114,7 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0) * set req is nullptr * set rsp is nullptr * 2. call IpcClientStub SendCmd with parameter - * 3. check result is DM_IPC_FAILED + * 3. check result is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -129,8 +129,8 @@ HWTEST_F(IpcClientStubTest, SendCmd_001, testing::ext::TestSize.Level0) sptr instance = new IpcClientStub(); // 2. call IpcClientStub SendCmd with parameter int ret = instance->SendCmd(cmdCode, req, rsp); - // 3. check result is DM_IPC_FAILED - ASSERT_EQ(ret, DM_IPC_FAILED); + // 3. check result is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_ipc_cmd_register.cpp b/test/unittest/UTTest_ipc_cmd_register.cpp index 8c029ac7bc806d880982bc909d1690a757641aa1..30b97dbd723983f066f32e5ca1d61149ba034bf0 100644 --- a/test/unittest/UTTest_ipc_cmd_register.cpp +++ b/test/unittest/UTTest_ipc_cmd_register.cpp @@ -60,7 +60,7 @@ namespace { * set MessageParcel data null * set IpcReq null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_NOT_REGISTER_FUNC + * 3. check ret is ERR_DM_REGISTER_FUNC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -75,8 +75,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_001, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_INVALID_VALUE - ASSERT_EQ(ret, DM_INVALID_VALUE); + // 3. check ret is ERR_DM_INPUT_PARAMETER_EMPTY + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } /** @@ -85,7 +85,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_001, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -100,8 +100,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_002, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_IPC_TRANSACTION_FAILED - ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -110,7 +110,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_002, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with pkgName not null * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -127,8 +127,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_003, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_IPC_TRANSACTION_FAILED - ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -137,7 +137,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_003, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with listener * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -156,8 +156,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_004, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_IPC_TRANSACTION_FAILED - ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -166,7 +166,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_004, testing::ext::TestSize.Level0) * set MessageParcel data null * set IpcRegisterListenerReq with listener * 2. call IpcCmdRegister OnRemoteRequest with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -185,8 +185,8 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_005, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data); - // 3. check ret is DM_IPC_TRANSACTION_FAILED - ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); } /** @@ -194,7 +194,7 @@ HWTEST_F(IpcCmdRegisterTest, SetRequest_005, testing::ext::TestSize.Level0) * @tc.desc: 1. set cmdCode 9999 * set MessageParcel reply null * 2. call IpcCmdRegister ReadResponse with parameter - * 3. check ret is DM_IPC_NOT_REGISTER_FUNC + * 3. check ret is ERR_DM_REGISTER_FUNC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -209,8 +209,8 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_001, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister ReadResponse with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); - // 3. check ret is DM_IPC_NOT_REGISTER_FUNC - ASSERT_EQ(ret, DM_IPC_NOT_REGISTER_FUNC); + // 3. check ret is ERR_DM_REGISTER_FUNC + ASSERT_EQ(ret, ERR_DM_REGISTER_FUNC); } /** @@ -294,7 +294,7 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_004, testing::ext::TestSize.Level0) * set MessageParcel reply null * set IpcRsp null * 2. call IpcCmdRegister ReadResponse with parameter - * 3. check ret is DM_IPC_TRANSACTION_FAILED + * 3. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -312,6 +312,9 @@ HWTEST_F(IpcCmdRegisterTest, ReadResponse_005, testing::ext::TestSize.Level0) std::shared_ptr rsp = std::make_shared(); // 2. call IpcCmdRegister OnRemoteRequest with parameter int ret = 0; + ret = IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp);; + // 3. check ret is ERR_DM_IPC + ASSERT_EQ(ret, ERR_DM_IPC); ret = IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); // 3. check ret is DM_IPC_TRANSACTION_FAILED ASSERT_EQ(ret, DM_IPC_TRANSACTION_FAILED); @@ -338,8 +341,8 @@ HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_001, testing::ext::TestSize.Level0) // 2. call IpcCmdRegister ReadResponse with parameter int ret = 0; ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - // 3. check ret is DM_IPC_NOT_REGISTER_FUNC - ASSERT_EQ(ret, DM_IPC_NOT_REGISTER_FUNC); + // 3. check ret is ERR_DM_REGISTER_FUNC + ASSERT_EQ(ret, ERR_DM_REGISTER_FUNC); } /** @@ -486,10 +489,10 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa std::string pkgName = pReq->GetPkgName(); sptr listener = pReq->GetListener(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteRemoteObject(listener)) { - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } return DM_OK; } @@ -504,7 +507,7 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr p { std::string pkgName = pBaseReq->GetPkgName(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } return DM_OK; } @@ -521,10 +524,10 @@ ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr pBaseReq, Mess std::string pkgName = pReq->GetPkgName(); std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } return DM_OK; } @@ -540,8 +543,8 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt pDmDeviceinfo = nullptr; pDmDeviceinfo = (DmDeviceInfo *)reply.ReadRawData(sizeof(DmDeviceInfo)); if (pDmDeviceinfo == nullptr) { - pRsp->SetErrCode(DM_IPC_TRANSACTION_FAILED); - return DM_IPC_TRANSACTION_FAILED; + pRsp->SetErrCode(ERR_DM_IPC); + return ERR_DM_IPC; } deviceInfoVec.emplace_back(*pDmDeviceinfo); } @@ -622,10 +625,10 @@ ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Mess std::string pkgName = pReq->GetPkgName(); const DmSubscribeInfo dmSubscribeInfo = pReq->GetSubscribeInfo(); if (!data.WriteString(pkgName)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteRawData(&dmSubscribeInfo, sizeof(DmSubscribeInfo))) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -642,10 +645,10 @@ ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Messa std::string pkgName = pReq->GetPkgName(); uint16_t subscribeId = pReq->GetSubscribeId(); if (!data.WriteString(pkgName)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteInt16((int16_t)subscribeId)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -666,16 +669,16 @@ ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Messag std::string deviceId = deviceInfo.deviceId; if (!data.WriteString(pkgName)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(extra)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteInt32(authType)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -693,10 +696,10 @@ ON_IPC_SET_REQUEST(UNAUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Mess DmDeviceInfo deviceInfo = pReq->GetDeviceInfo(); std::string deviceId = deviceInfo.deviceId; if (!data.WriteString(pkgName)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } if (!data.WriteString(deviceId)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -712,7 +715,7 @@ ON_IPC_SET_REQUEST(VERIFY_AUTHENTICATION, std::shared_ptr pBaseReq, Mess std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string authPara = pReq->GetAuthPara(); if (!data.WriteString(authPara)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -728,7 +731,7 @@ ON_IPC_SET_REQUEST(SERVER_GET_DMFA_INFO, std::shared_ptr pBaseReq, Messa std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string packagename = pReq->GetPkgName(); if (!data.WriteString(packagename)) { - return DM_IPC_FLATTEN_OBJECT; + return ERR_DM_IPC_WRITE; } return DM_OK; } @@ -756,10 +759,10 @@ ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr pBaseReq, int32_t action = pReq->GetOperation(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteInt32(action)) { - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -779,10 +782,10 @@ ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -802,10 +805,10 @@ ON_IPC_SET_REQUEST(UNREGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseR std::string extra = pReq->GetExtra(); if (!data.WriteString(pkgName)) { - return DM_IPC_TRANSACTION_FAILED; + return ERR_DM_IPC; } if (!data.WriteString(extra)) { - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; @@ -825,7 +828,7 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(DM_IPC_COPY_FAILED); + reply.WriteInt32(ERR_DM_IPC_COPY); return DM_OK; } switch (deviceState) { @@ -856,8 +859,8 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, MessageParcel &data, MessageParcel &reply) size_t deviceSize = sizeof(DmDeviceInfo); void *deviceInfo = (void *)data.ReadRawData(deviceSize); if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) { - reply.WriteInt32(DM_IPC_COPY_FAILED); - return DM_IPC_COPY_FAILED; + reply.WriteInt32(ERR_DM_IPC_COPY); + return ERR_DM_IPC_COPY; } DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceInfo); reply.WriteInt32(DM_OK); @@ -908,7 +911,7 @@ ON_IPC_CMD(SERVER_DEVICE_FA_NOTIFY, MessageParcel &data, MessageParcel &reply) std::string paramJson = data.ReadString(); DeviceManagerNotify::GetInstance().OnFaCall(packagename, paramJson); if (!reply.WriteInt32(DM_OK)) { - return DM_WRITE_FAILED; + return ERR_DM_WRITE_FAILED; } return DM_OK; } diff --git a/test/unittest/UTTest_ipc_server_client_proxy.cpp b/test/unittest/UTTest_ipc_server_client_proxy.cpp index 4817cdf411b264625d79e110972321aac4201c00..e6254856836630d999e0b03036a5175cbab675d1 100644 --- a/test/unittest/UTTest_ipc_server_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_server_client_proxy.cpp @@ -66,7 +66,7 @@ HWTEST_F(IpcServerClientProxyTest, SendCmd_001, testing::ext::TestSize.Level0) auto instance = new IpcServerClientProxy(remoteObject); int ret = instance->SendCmd(cmdCode, nullptr, nullptr); // 4. check ret is DEVICEMANAGER_NULLPTR - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -105,8 +105,8 @@ HWTEST_F(IpcServerClientProxyTest, SendCmd_002, testing::ext::TestSize.Level0) int ret = 0; std::shared_ptr ipcServerListener = std::make_shared(); ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -145,8 +145,8 @@ HWTEST_F(IpcServerClientProxyTest, SendCmd_003, testing::ext::TestSize.Level0) int ret = 0; std::shared_ptr ipcServerListener = std::make_shared(); ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -185,8 +185,8 @@ HWTEST_F(IpcServerClientProxyTest, SendCmd_004, testing::ext::TestSize.Level0) int ret = 0; std::shared_ptr ipcServerListener = std::make_shared(); ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_ipc_server_listener.cpp b/test/unittest/UTTest_ipc_server_listener.cpp index d9077971d44a3bdb963833f97030701ea2c5af1b..b483764a07e38094979b5c82eedfef372924f580 100644 --- a/test/unittest/UTTest_ipc_server_listener.cpp +++ b/test/unittest/UTTest_ipc_server_listener.cpp @@ -56,7 +56,7 @@ namespace { * set req not null * set rsp not null * 3. call IpcServerListener SendRequest - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -76,8 +76,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_001, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -109,8 +109,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_002, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -121,7 +121,7 @@ HWTEST_F(IpcServerListenerTest, SendRequest_002, testing::ext::TestSize.Level0) * set req not null * set rsp not null * 3. call IpcServerListener SendRequest - * 4. check ret is DM_IPC_FAILED + * 4. check ret is ERR_DM_IPC * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -142,8 +142,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_003, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not DM_FAILED - ASSERT_NE(ret, DM_FAILED); + // 4. check ret is not ERR_DM_FAILED + ASSERT_NE(ret, ERR_DM_FAILED); } /** @@ -154,7 +154,7 @@ HWTEST_F(IpcServerListenerTest, SendRequest_003, testing::ext::TestSize.Level0) * set req not null * set rsp not null * 3. call IpcServerListener SendRequest - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -175,8 +175,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_004, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -187,7 +187,7 @@ HWTEST_F(IpcServerListenerTest, SendRequest_004, testing::ext::TestSize.Level0) * set req not null * set rsp not null * 3. call IpcServerListener SendRequest - * 4. check ret is DM_POINT_NULL + * 4. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -208,8 +208,8 @@ HWTEST_F(IpcServerListenerTest, SendRequest_005, testing::ext::TestSize.Level0) // 3. call IpcServerListener SendRequest std::shared_ptr ipcServerListener = std::make_shared(); int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is DM_POINT_NULL - ASSERT_EQ(ret, DM_POINT_NULL); + // 4. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** diff --git a/test/unittest/UTTest_ipc_server_stub.cpp b/test/unittest/UTTest_ipc_server_stub.cpp index cb0385a5ffe3c0fa033bc278a037423756268078..a4686000dec8d4bc8e3aaf4051bc90c893bf5005 100644 --- a/test/unittest/UTTest_ipc_server_stub.cpp +++ b/test/unittest/UTTest_ipc_server_stub.cpp @@ -219,7 +219,7 @@ HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_001, testing::ext::Tes int ret = 0; sptr listener = nullptr; ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -251,7 +251,7 @@ HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_003, testing::ext::Tes int ret = 0; sptr listener = sptr(new IpcClientStub()); ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -305,7 +305,7 @@ HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_005, testing::ext::Tes /** * @tc.name: UnRegisterDeviceManagerListener_001 * @tc.desc: 1. Call IpcServerStub UnRegisterDeviceManagerListener - * 2. check ret is DM_POINT_NULL + * 2. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -314,7 +314,7 @@ HWTEST_F(IpcServerStubTest, UnRegisterDeviceManagerListener_001, testing::ext::T std::string pkgName = ""; int ret = 0; ret = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(pkgName); - ASSERT_EQ(ret, DM_POINT_NULL); + ASSERT_EQ(ret, ERR_DM_POINT_NULL); } /** @@ -496,7 +496,7 @@ HWTEST_F(IpcServerStubTest, GetDmListener_003, testing::ext::TestSize.Level0) * @tc.name: GetDmListener_004 * @tc.desc: 1. Set pkgName is com.ohos.test * 2. Call IpcServerStub GetDmListener - * 3. check ret is DM_POINT_NULL + * 3. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -508,8 +508,8 @@ HWTEST_F(IpcServerStubTest, GetDmListener_004, testing::ext::TestSize.Level0) sptr listener = sptr(new IpcClientStub()); // 2. Call IpcServerStub RegisterDeviceManagerListener with param result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); - // 3. check ret is DM_POINT_NULL - ASSERT_EQ(result, DM_POINT_NULL); + // 3. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(result, ERR_DM_POINT_NULL); sptr ret = nullptr; // 2. Call IpcServerStub UnRegisterDeviceManagerListener ret = IpcServerStub::GetInstance().GetDmListener(pkgName); @@ -521,7 +521,7 @@ HWTEST_F(IpcServerStubTest, GetDmListener_004, testing::ext::TestSize.Level0) * @tc.name: GetDmListener_005 * @tc.desc: 1. Set pkgName is com.ohos.test * 2. Call IpcServerStub GetDmListener - * 3. check ret is DM_POINT_NULL + * 3. check ret is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -533,8 +533,8 @@ HWTEST_F(IpcServerStubTest, GetDmListener_005, testing::ext::TestSize.Level0) sptr listener = nullptr; // 2. Call IpcServerStub RegisterDeviceManagerListener with param result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); - // 3. check ret is DM_POINT_NULL - ASSERT_EQ(result, DM_POINT_NULL); + // 3. check ret is ERR_DM_POINT_NULL + ASSERT_EQ(result, ERR_DM_POINT_NULL); sptr ret = nullptr; // 2. Call IpcServerStub UnRegisterDeviceManagerListener ret = IpcServerStub::GetInstance().GetDmListener(pkgName); diff --git a/test/unittest/UTTest_multiple_user_connector.cpp b/test/unittest/UTTest_multiple_user_connector.cpp index 7ac5fe35b5caeb535f48105c7fd5591bffbf922e..5e917427eded9af5978838a388547e055f654513 100644 --- a/test/unittest/UTTest_multiple_user_connector.cpp +++ b/test/unittest/UTTest_multiple_user_connector.cpp @@ -37,7 +37,7 @@ namespace { * @tc.name: OnDecisionFilterResult_001 * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new * to construct an environment where the device has been discovered, and stop discovering - * the device. Its return value is DM_INPUT_PARA_EMPTY + * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -52,7 +52,7 @@ HWTEST_F(MultipleUserConnectorTest, GetCurrentAccountUserID_001, testing::ext::T * @tc.name: SetSwitchOldUserId_001 * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new * to construct an environment where the device has been discovered, and stop discovering - * the device. Its return value is DM_INPUT_PARA_EMPTY + * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -69,7 +69,7 @@ HWTEST_F(MultipleUserConnectorTest, SetSwitchOldUserId_001, testing::ext::TestSi * @tc.name: GetSwitchOldUserId_001 * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new * to construct an environment where the device has been discovered, and stop discovering - * the device. Its return value is DM_INPUT_PARA_EMPTY + * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/test/unittest/UTTest_pin_auth.cpp b/test/unittest/UTTest_pin_auth.cpp index cb1d0cecf064cfe2d6dbbd89c92c359a07103080..0c5b35de33799f124491449ba8f6b35dae8388db 100644 --- a/test/unittest/UTTest_pin_auth.cpp +++ b/test/unittest/UTTest_pin_auth.cpp @@ -49,7 +49,7 @@ std::shared_ptr authManager = std::make_shared(softbusConnector, listener, hiChainConnector); /** * @tc.name: DmAuthManager::ShowAuthInfo_001 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -58,12 +58,12 @@ HWTEST_F(PinAuthTest, ShowAuthInfo_001, testing::ext::TestSize.Level0) std::shared_ptr pinAuth = std::make_shared(); std::string authToken = "123456"; int32_t ret = pinAuth->ShowAuthInfo(authToken, authManager); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::ShowAuthInfo_002 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -74,7 +74,7 @@ HWTEST_F(PinAuthTest, ShowAuthInfo_002, testing::ext::TestSize.Level0) jsonObject[PIN_TOKEN] = 123456; std::string authToken = jsonObject.dump(); int32_t ret = pinAuth->ShowAuthInfo(authToken, authManager); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -110,7 +110,7 @@ HWTEST_F(PinAuthTest, ShowAuthInfo_004, testing::ext::TestSize.Level0) } /** * @tc.name: DmAuthManager::StartAuth_001 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -119,12 +119,12 @@ HWTEST_F(PinAuthTest, StartAuth_001, testing::ext::TestSize.Level0) std::shared_ptr pinAuth = std::make_shared(); std::string authToken = ""; int32_t ret = pinAuth->StartAuth(authToken, nullptr); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::StartAuth_002 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -133,12 +133,12 @@ HWTEST_F(PinAuthTest, StartAuth_002, testing::ext::TestSize.Level0) std::shared_ptr pinAuth = std::make_shared(); std::string authToken = ""; int32_t ret = pinAuth->StartAuth(authToken, authManager); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::StartAuth_003 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -149,7 +149,7 @@ HWTEST_F(PinAuthTest, StartAuth_003, testing::ext::TestSize.Level0) jsonObject[PIN_TOKEN] = 123456; std::string authToken = jsonObject.dump(); int32_t ret = pinAuth->StartAuth(authToken, authManager); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -170,7 +170,7 @@ HWTEST_F(PinAuthTest, StartAuth_004, testing::ext::TestSize.Level0) /** * @tc.name: DmAuthManager::VerifyAuthentication_001 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -180,7 +180,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_001, testing::ext::TestSize.Level0) std::string authToken; std::string authParam = "1"; int32_t ret = pinAuth->VerifyAuthentication(authToken, authParam); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** @@ -195,7 +195,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_002, testing::ext::TestSize.Level0) std::string authToken; std::string authParam = "0"; int32_t ret = pinAuth->VerifyAuthentication(authToken, authParam); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: DmAuthManager::VerifyAuthentication_003 @@ -220,7 +220,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_003, testing::ext::TestSize.Level0) /** * @tc.name: DmAuthManager::VerifyAuthentication_004 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_AUTH_INPUT_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_AUTH_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -236,12 +236,12 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_004, testing::ext::TestSize.Level0) std::string authToken = authTokenJson.dump(); std::string authParam = authParamJson.dump(); int32_t ret = pinAuth->VerifyAuthentication(authToken, authParam); - ASSERT_EQ(ret, DM_AUTH_INPUT_FAILED); + ASSERT_EQ(ret, ERR_DM_AUTH_INPUT_PARAMETER_EMPTY); } /** * @tc.name: DmAuthManager::VerifyAuthentication_005 - * @tc.desc: Call unauthenticateddevice to check whether the return value is DM_FAILED + * @tc.desc: Call unauthenticateddevice to check whether the return value is ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -259,7 +259,7 @@ HWTEST_F(PinAuthTest, VerifyAuthentication_005, testing::ext::TestSize.Level0) pinAuth->VerifyAuthentication(authToken, authParam); pinAuth->VerifyAuthentication(authToken, authParam); int32_t ret = pinAuth->VerifyAuthentication(authToken, authParam); - ASSERT_EQ(ret, DM_FAILED); + ASSERT_EQ(ret, ERR_DM_FAILED); } } } // namespace DistributedHardware diff --git a/test/unittest/UTTest_pin_auth_ui.cpp b/test/unittest/UTTest_pin_auth_ui.cpp index 7961e55c4117c1c906a272e9cecf22f17fb3ec1f..448854f0d2a60ba1e2d5f14f2c3de177fcfeb8c9 100644 --- a/test/unittest/UTTest_pin_auth_ui.cpp +++ b/test/unittest/UTTest_pin_auth_ui.cpp @@ -51,7 +51,7 @@ std::shared_ptr authManager = std::make_shared(softbusConnector, listener, hiChainConnector); /** * @tc.name: PinAuthUi::ShowPinDialog_001 - * @tc.desc: Call ShowPinDialog to check whether the return value is DM_POINT_NULL + * @tc.desc: Call ShowPinDialog to check whether the return value is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -79,7 +79,7 @@ HWTEST_F(PinAuthUiTest, ShowPinDialog_002, testing::ext::TestSize.Level0) /** * @tc.name: PinAuthUi::ShowPinDialog_001 - * @tc.desc: Call InputPinDialog to check whether the return value is DM_POINT_NULL + * @tc.desc: Call InputPinDialog to check whether the return value is ERR_DM_POINT_NULL * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/test/unittest/UTTest_profile_connector.cpp b/test/unittest/UTTest_profile_connector.cpp index 5b5fd53abc53b31234c72e0daa54e72714faba75..954577f14660eb583ac4670ebf832e302643521c 100644 --- a/test/unittest/UTTest_profile_connector.cpp +++ b/test/unittest/UTTest_profile_connector.cpp @@ -48,7 +48,7 @@ std::shared_ptr deviceStateMgr = std::make_sharedStartDiscovery(dmSubscribeInfo); - EXPECT_EQ(ret, DM_DISCOVERY_FAILED); + EXPECT_EQ(ret, ERR_DM_DISCOVERY); } /** * @tc.name: StopDiscovery_001 - * @tc.desc: get StartDiscovery to wroing master and return DM_DISCOVERY_FAILED + * @tc.desc: get StartDiscovery to wroing master and return ERR_DM_DISCOVERY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -298,7 +298,7 @@ HWTEST_F(SoftbusConnectorTest, StopDiscovery_001, testing::ext::TestSize.Level0) /** * @tc.name: GetUdidByNetworkId_001 - * @tc.desc: get StartDiscovery to wroing master and return DM_DISCOVERY_FAILED + * @tc.desc: get StartDiscovery to wroing master and return ERR_DM_DISCOVERY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -312,7 +312,7 @@ HWTEST_F(SoftbusConnectorTest, GetUdidByNetworkId_001, testing::ext::TestSize.Le /** * @tc.name: GetUuidByNetworkId_001 - * @tc.desc: get StartDiscovery to wroing master and return DM_DISCOVERY_FAILED + * @tc.desc: get StartDiscovery to wroing master and return ERR_DM_DISCOVERY * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -395,7 +395,7 @@ HWTEST_F(SoftbusConnectorTest, HaveDeviceInMap_002, testing::ext::TestSize.Level /** * @tc.name: GetConnectionIpAddress_001 - * @tc.desc: set deviceId null,and return DM_FAILED + * @tc.desc: set deviceId null,and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -404,12 +404,12 @@ HWTEST_F(SoftbusConnectorTest, GetConnectionIpAddress_001, testing::ext::TestSiz std::string deviceId; std::string ipAddress = "123456"; int ret = softbusConnector->GetConnectionIpAddress(deviceId, ipAddress); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: GetConnectionIpAddress_002 - * @tc.desc: set some corrort para,and return DM_FAILED + * @tc.desc: set some corrort para,and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -418,11 +418,11 @@ HWTEST_F(SoftbusConnectorTest, GetConnectionIpAddress_002, testing::ext::TestSiz std::string deviceId = "213456"; std::string ipAddress = "123456"; int ret = softbusConnector->GetConnectionIpAddress(deviceId, ipAddress); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: GetConnectionIpAddress_003 - * @tc.desc: set deviceInfo.addrNum = -1;go to second master and return DM_FAILED + * @tc.desc: set deviceInfo.addrNum = -1;go to second master and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -433,7 +433,7 @@ HWTEST_F(SoftbusConnectorTest, GetConnectionIpAddress_003, testing::ext::TestSiz std::string ipAddress; std::string deviceId = "3338848"; int ret = softbusConnector->GetConnectionIpAddress(deviceId, ipAddress); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** diff --git a/test/unittest/UTTest_softbus_session.cpp b/test/unittest/UTTest_softbus_session.cpp index c1bcda1570866ba9750afcbcb7d98d50bfc2bde8..ce94dc0514262a72113401fe6224115599c37c5f 100644 --- a/test/unittest/UTTest_softbus_session.cpp +++ b/test/unittest/UTTest_softbus_session.cpp @@ -72,7 +72,7 @@ HWTEST_F(SoftbusSessionTest, OpenAuthSession_002, testing::ext::TestSize.Level0) /** * @tc.name: SendData_001 - * @tc.desc: set message null and return DM_FAILED + * @tc.desc: set message null and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -81,12 +81,12 @@ HWTEST_F(SoftbusSessionTest, SendData_001, testing::ext::TestSize.Level0) std::string message = ""; int32_t sessionId = -1; int ret = softbusSession->SendData(sessionId, message); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** * @tc.name: SendData_002 - * @tc.desc: set sessionId = 0 ,go to the SendBytes'smaster and return DM_FAILED + * @tc.desc: set sessionId = 0 ,go to the SendBytes'smaster and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -100,7 +100,7 @@ HWTEST_F(SoftbusSessionTest, SendData_002, testing::ext::TestSize.Level0) int32_t sessionId = 0; softbusSession->RegisterSessionCallback(std::shared_ptr(discoveryMgr)); int ret = softbusSession->SendData(sessionId, message); - EXPECT_EQ(ret, DM_FAILED); + EXPECT_EQ(ret, ERR_DM_FAILED); } /** @@ -170,7 +170,7 @@ HWTEST_F(SoftbusSessionTest, RegisterSessionCallback_001, testing::ext::TestSize /** * @tc.name: UnRegisterSessionCallback_001 - * @tc.desc: set info to null and return DM_FAILED + * @tc.desc: set info to null and return ERR_DM_FAILED * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/test/unittest/auth_request_state.cpp b/test/unittest/auth_request_state.cpp index ae2d967bdb80306dbf40a954d3acbc15e695692b..7163671855bc15d4ad2876b6d516fbfa100b2ccd 100644 --- a/test/unittest/auth_request_state.cpp +++ b/test/unittest/auth_request_state.cpp @@ -48,7 +48,7 @@ int32_t AuthRequestState::TransitionTo(std::shared_ptr state) std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } state->SetAuthManager(stateAuthManager); stateAuthManager->SetAuthRequestState(state); @@ -68,7 +68,7 @@ int32_t AuthRequestInitState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->EstablishAuthChannel(context_->deviceId); return DM_OK; @@ -84,7 +84,7 @@ int32_t AuthRequestNegotiateState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->StartNegotiate(context_->sessionId); return DM_OK; @@ -100,7 +100,7 @@ int32_t AuthRequestNegotiateDoneState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->SendAuthRequest(context_->sessionId); return DM_OK; @@ -116,7 +116,7 @@ int32_t AuthRequestReplyState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->StartRespAuthProcess(); return DM_OK; @@ -133,7 +133,7 @@ int32_t AuthRequestInputState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowStartAuthDialog(); return DM_OK; @@ -150,7 +150,7 @@ int32_t AuthRequestJoinState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AddMember(context_->deviceId); return DM_OK; @@ -166,7 +166,7 @@ int32_t AuthRequestNetworkState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->JoinNetwork(); return DM_OK; @@ -182,7 +182,7 @@ int32_t AuthRequestFinishState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AuthenticateFinish(); return DM_OK; diff --git a/test/unittest/auth_response_state.cpp b/test/unittest/auth_response_state.cpp index c2725a515ac61313384bb09a314e766b1cd860e2..50e566b0097ff71ae88d4522b24e29eb00ef8d0f 100644 --- a/test/unittest/auth_response_state.cpp +++ b/test/unittest/auth_response_state.cpp @@ -49,7 +49,7 @@ int32_t AuthResponseState::TransitionTo(std::shared_ptr state std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } state->SetAuthManager(stateAuthManager); stateAuthManager->SetAuthResponseState(state); @@ -80,7 +80,7 @@ int32_t AuthResponseNegotiateState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->RespNegotiate(context_->sessionId); return DM_OK; @@ -97,7 +97,7 @@ int32_t AuthResponseConfirmState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowConfigDialog(); return DM_OK; @@ -114,7 +114,7 @@ int32_t AuthResponseGroupState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->CreateGroup(); return DM_OK; @@ -130,7 +130,7 @@ int32_t AuthResponseShowState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->ShowAuthInfoDialog(); return DM_OK; @@ -146,7 +146,7 @@ int32_t AuthResponseFinishState::Enter() std::shared_ptr stateAuthManager = authManager_.lock(); if (stateAuthManager == nullptr) { LOGE("AuthRequestState::authManager_ null"); - return DM_FAILED; + return ERR_DM_FAILED; } stateAuthManager->AuthenticateFinish(); return DM_OK; diff --git a/test/unittest/device_manager_impl_test.cpp b/test/unittest/device_manager_impl_test.cpp index ead0313149f1696364eedc6ded0235bd738e10ce..c29883e9f1e9f3b8f1cb2f09e1fdf1aed010e06e 100644 --- a/test/unittest/device_manager_impl_test.cpp +++ b/test/unittest/device_manager_impl_test.cpp @@ -43,7 +43,7 @@ HWTEST_F(DeviceManagerImplTest, InitDeviceManager, testing::ext::TestSize.Level0 { std::string packName = ""; int32_t ret = DeviceManager::GetInstance().InitDeviceManager(packName, nullptr); - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } HWTEST_F(DeviceManagerImplTest, AuthenticateDevice1, testing::ext::TestSize.Level0) @@ -54,7 +54,7 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice1, testing::ext::TestSize.Leve std::string extra = ""; std::shared_ptr callback = nullptr; int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } HWTEST_F(DeviceManagerImplTest, AuthenticateDevice2, testing::ext::TestSize.Level0) @@ -68,9 +68,9 @@ HWTEST_F(DeviceManagerImplTest, AuthenticateDevice2, testing::ext::TestSize.Leve DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1) - .WillOnce(testing::Return(DM_FAILED)); + .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(packName, authType, dmDeviceInfo, extra, callback); - ASSERT_EQ(ret, DM_IPC_FAILED); + ASSERT_EQ(ret, ERR_DM_IPC); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -97,7 +97,7 @@ HWTEST_F(DeviceManagerImplTest, VerifyAuthentication1, testing::ext::TestSize.Le std::string authPara = ""; std::shared_ptr callback = nullptr; int32_t ret = DeviceManager::GetInstance().VerifyAuthentication(packName, authPara, callback); - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } HWTEST_F(DeviceManagerImplTest, VerifyAuthentication2, testing::ext::TestSize.Level0) @@ -109,9 +109,9 @@ HWTEST_F(DeviceManagerImplTest, VerifyAuthentication2, testing::ext::TestSize.Le DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1) - .WillOnce(testing::Return(DM_FAILED)); + .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().VerifyAuthentication(packName, authPara, callback); - ASSERT_EQ(ret, DM_IPC_FAILED); + ASSERT_EQ(ret, ERR_DM_IPC); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } @@ -137,7 +137,7 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery1, testing::ext::TestSize.Le std::string extra = ""; std::shared_ptr callback = nullptr; int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, callback); - ASSERT_EQ(ret, DM_INVALID_VALUE); + ASSERT_EQ(ret, ERR_DM_INPUT_PARAMETER_EMPTY); } HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery2, testing::ext::TestSize.Level0) @@ -166,9 +166,9 @@ HWTEST_F(DeviceManagerImplTest, StartDeviceDiscovery3, testing::ext::TestSize.Le DeviceManagerImpl::GetInstance().ipcClientProxy_ = mockInstance; EXPECT_CALL(*mockInstance, SendRequest(testing::_, testing::_, testing::_)) .Times(1) - .WillOnce(testing::Return(DM_FAILED)); + .WillOnce(testing::Return(ERR_DM_FAILED)); int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(packName, subscribeInfo, extra, test_callback_); - ASSERT_EQ(ret, DM_IPC_FAILED); + ASSERT_EQ(ret, ERR_DM_IPC); DeviceManagerImpl::GetInstance().ipcClientProxy_ = nullptr; } } // namespace diff --git a/test/unittest/mock/device_auth.cpp b/test/unittest/mock/device_auth.cpp index c3076a3d4e7c13f3a81a9eabe3a4fd13c2de387c..9a15831107848a80b6bcb14281f28ef43e286948 100644 --- a/test/unittest/mock/device_auth.cpp +++ b/test/unittest/mock/device_auth.cpp @@ -19,7 +19,7 @@ int32_t (*deleteGroup)(int64_t requestId, const char *appId, const char *disbandParams) { if (disbandParams == 0) { - return DM_FAILED; + return ERR_DM_FAILED; } return DM_OK; @@ -37,7 +37,7 @@ int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char ** int32_t (*createGroup)(int64_t requestId, const char *appId, const char *createParams) { if (requestId == 0) { - return DM_FAILED; + return ERR_DM_FAILED; } (void)appId; (void)createParams; diff --git a/utils/src/dm_hash.cpp b/utils/src/dm_hash.cpp index 3ee31684821e432992c6294b17f8244f1d446942..4e12dc526c7a23bb36f2433a10e22b983bfca8f3 100644 --- a/utils/src/dm_hash.cpp +++ b/utils/src/dm_hash.cpp @@ -24,7 +24,7 @@ int32_t GetUdidHash(uint8_t *udid, int32_t udidDataLen, uint8_t outudidData[32]) LOGI("GetUdidHash"); if (udid == nullptr || *udid < 0) { LOGE("udid is nullptr or dataLen: %d", udidDataLen); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } mbedtls_md_context_t ctx; const mbedtls_md_info_t *info; @@ -33,35 +33,35 @@ int32_t GetUdidHash(uint8_t *udid, int32_t udidDataLen, uint8_t outudidData[32]) info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); if (info == nullptr) { LOGE("info is nullptr"); - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } int32_t ret = DM_OK; do { ret = mbedtls_md_setup(&ctx, info, 0); if (ret != 0) { LOGE("mbedtls_md_setup is fail"); - ret = DM_FAILED; + ret = ERR_DM_FAILED; break; } ret = mbedtls_md_starts(&ctx); if (ret != 0) { LOGE("mbedtls_md_starts is fail"); - ret = DM_FAILED; + ret = ERR_DM_FAILED; break; } ret = mbedtls_md_update(&ctx, udid, udidDataLen); if (ret != 0) { LOGE("mbedtls_md_update is fail"); - ret = DM_FAILED; + ret = ERR_DM_FAILED; break; } ret = mbedtls_md_finish(&ctx, outudidData); if (ret != 0) { LOGE("mbedtls_md_finish is fail"); - ret = DM_FAILED; + ret = ERR_DM_FAILED; break; } ret = DM_OK; diff --git a/utils/src/dm_random.cpp b/utils/src/dm_random.cpp index 01daea9dfb537f5de0d82d0134bf9cb442bd20ac..21dff422e47ab2e5d1667ea9037ecb6573cf189f 100644 --- a/utils/src/dm_random.cpp +++ b/utils/src/dm_random.cpp @@ -55,7 +55,7 @@ int32_t GetRandomData(uint8_t *randStr, uint32_t len) { mbedtls_entropy_context *entropy = nullptr; mbedtls_ctr_drbg_context *ctrDrbg = nullptr; - int32_t ret = DM_FAILED; + int32_t ret = ERR_DM_FAILED; do { if (randStr == nullptr || len == 0) { break; diff --git a/utils/src/ipc/lite/ipc_cmd_register.cpp b/utils/src/ipc/lite/ipc_cmd_register.cpp index 02db4ea6ef681b5785c30c0052e2c790eb9d29b3..86f6737262cbacf464dd09d534ddb0958ca3df11 100644 --- a/utils/src/ipc/lite/ipc_cmd_register.cpp +++ b/utils/src/ipc/lite/ipc_cmd_register.cpp @@ -28,7 +28,7 @@ int32_t IpcCmdRegister::SetRequest(int32_t cmdCode, std::shared_ptr pBas auto setRequestMapIter = setIpcRequestFuncMap_.find(cmdCode); if (setRequestMapIter == setIpcRequestFuncMap_.end()) { LOGE("cmdCode:%d not register SetRequestFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } return (setRequestMapIter->second)(pBaseReq, request, buffer, buffLen); } @@ -38,7 +38,7 @@ int32_t IpcCmdRegister::ReadResponse(int32_t cmdCode, IpcIo &reply, std::shared_ auto readResponseMapIter = readResponseFuncMap_.find(cmdCode); if (readResponseMapIter == readResponseFuncMap_.end()) { LOGE("cmdCode:%d not register ReadResponseFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } return (readResponseMapIter->second)(reply, pBaseRsp); } @@ -48,7 +48,7 @@ int32_t IpcCmdRegister::OnIpcCmd(int32_t cmdCode, IpcIo &reply) auto onIpcCmdMapIter = onIpcCmdFuncMap_.find(cmdCode); if (onIpcCmdMapIter == onIpcCmdFuncMap_.end()) { LOGE("cmdCode:%d not register OnIpcCmdFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } (onIpcCmdMapIter->second)(reply); return DM_OK; @@ -59,7 +59,7 @@ int32_t IpcCmdRegister::OnIpcServerCmd(int32_t cmdCode, IpcIo &req, IpcIo &reply auto onIpcServerCmdMapIter = onIpcServerCmdFuncMap_.find(cmdCode); if (onIpcServerCmdMapIter == onIpcServerCmdFuncMap_.end()) { LOGE("cmdCode:%d not register OnIpcCmdFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } (onIpcServerCmdMapIter->second)(req, reply); return DM_OK; diff --git a/utils/src/ipc/standard/ipc_cmd_register.cpp b/utils/src/ipc/standard/ipc_cmd_register.cpp index 9ecd6f083c2f93e7ba998906965d6b9d18cef603..33f7c0ef444ae16716927e699ffbcdac7ef08de5 100644 --- a/utils/src/ipc/standard/ipc_cmd_register.cpp +++ b/utils/src/ipc/standard/ipc_cmd_register.cpp @@ -28,12 +28,12 @@ int32_t IpcCmdRegister::SetRequest(int32_t cmdCode, std::shared_ptr pBas int32_t ret = DM_OK; if (cmdCode < 0 || cmdCode >= UNREGISTER_DEV_STATE_CALLBACK || pBaseReq == nullptr) { LOGE("IpcCmdRegister::SetRequest cmdCode param invalid!"); - return DM_INVALID_VALUE; + return ERR_DM_INPUT_PARAMETER_EMPTY; } if (setIpcRequestFuncMap_.count(cmdCode) == 0) { LOGE("cmdCode:%d not register SetRequestFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } auto setRequestMapIter = setIpcRequestFuncMap_.find(cmdCode); @@ -48,10 +48,10 @@ int32_t IpcCmdRegister::ReadResponse(int32_t cmdCode, MessageParcel &reply, std: auto readResponseMapIter = readResponseFuncMap_.find(cmdCode); if (readResponseMapIter == readResponseFuncMap_.end()) { LOGE("cmdCode:%d not register ReadResponseFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } if (readResponseMapIter->second == nullptr) { - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return (readResponseMapIter->second)(reply, pBaseRsp); } @@ -61,10 +61,10 @@ int32_t IpcCmdRegister::OnIpcCmd(int32_t cmdCode, MessageParcel &data, MessagePa auto onIpcCmdMapIter = onIpcCmdFuncMap_.find(cmdCode); if (onIpcCmdMapIter == onIpcCmdFuncMap_.end()) { LOGE("cmdCode:%d not register OnIpcCmdFunc", cmdCode); - return DM_IPC_NOT_REGISTER_FUNC; + return ERR_DM_REGISTER_FUNC; } if (onIpcCmdMapIter->second == nullptr) { - return DM_POINT_NULL; + return ERR_DM_POINT_NULL; } return (onIpcCmdMapIter->second)(data, reply); }