diff --git a/common/include/dm_adapter_crypto.h b/common/include/dm_adapter_crypto.h index ecc375785fb6effd1c8ea2d85aa8eaa1ee91ff1f..621a338d18d23967bdacc9210e7cfa6dd327981a 100644 --- a/common/include/dm_adapter_crypto.h +++ b/common/include/dm_adapter_crypto.h @@ -54,10 +54,10 @@ typedef struct { class DmAdapterCrypto { public: - static int32_t MbedAesGcmEncrypt(AesGcmCipherKey *cipherKey, const unsigned char *plainText, int32_t plainTextSize, + static void MbedAesGcmEncrypt(AesGcmCipherKey *cipherKey, const unsigned char *plainText, int32_t plainTextSize, unsigned char *cipherText, int32_t cipherTextLen); - static int32_t MbedAesGcmDecrypt(AesGcmCipherKey *cipherKey, const unsigned char *cipherText, + static void MbedAesGcmDecrypt(AesGcmCipherKey *cipherKey, const unsigned char *cipherText, int32_t cipherTextSize, unsigned char *plain, int32_t plainLen); #endif // !AES_GCM_H }; diff --git a/common/src/dfx/standard/dm_hidumper.cpp b/common/src/dfx/standard/dm_hidumper.cpp index 74af394b8fe320d8b803614cf59c87911f4c792f..eeb2101b9a0a7912128acb7e97ad037c067064e8 100644 --- a/common/src/dfx/standard/dm_hidumper.cpp +++ b/common/src/dfx/standard/dm_hidumper.cpp @@ -19,12 +19,13 @@ #include // for pair #include "dm_anonymous.h" // for GetAnonyString -#include "dm_constants.h" // for DM_OK, ERR_DM_FAILED #include "dm_log.h" // for LOGI, LOGE namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(HiDumpHelper); +constexpr int32_t DM_OK = 0; +constexpr int32_t ERR_DM_FAILED = -20000; int32_t HiDumpHelper::HiDump(const std::vector& args, std::string &result) { LOGI("HiDumpHelper start."); diff --git a/common/src/dfx/standard/dm_hisysevent.cpp b/common/src/dfx/standard/dm_hisysevent.cpp index b2e71a090df8554b4ede59a5f7649b94251bf945..371896a16125a59813094d44bd6daa973c6da7be 100644 --- a/common/src/dfx/standard/dm_hisysevent.cpp +++ b/common/src/dfx/standard/dm_hisysevent.cpp @@ -15,13 +15,13 @@ #include "dm_hisysevent.h" -#include "dm_constants.h" // for DM_OK #include "dm_log.h" // for LOGE #include "hisysevent.h" // for HiSysEvent, HiSysEvent::Domain, HiSysEvent... #include "unistd.h" // for getpid, getuid namespace OHOS { namespace DistributedHardware { +constexpr int32_t DM_OK = 0; void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg) { int32_t res = HiSysEventWrite( diff --git a/common/src/dm_adapter_crypto.cpp b/common/src/dm_adapter_crypto.cpp index d66860d49f6ef45731cf5b7a42449cd65eb065ce..a8fe53d7870975984320786211c1270dd6dfef5b 100644 --- a/common/src/dm_adapter_crypto.cpp +++ b/common/src/dm_adapter_crypto.cpp @@ -25,7 +25,6 @@ #include "mbedtls/platform.h" #include "md.h" #include "dm_log.h" -#include "dm_constants.h" namespace OHOS { namespace DistributedHardware { @@ -60,7 +59,7 @@ namespace DistributedHardware { #define EVP_AES_128_KEYLEN 16 #define EVP_AES_256_KEYLEN 32 -int32_t DmAdapterCrypto::MbedAesGcmEncrypt(AesGcmCipherKey *cipherKey, const unsigned char *plainText, +void DmAdapterCrypto::MbedAesGcmEncrypt(AesGcmCipherKey *cipherKey, const unsigned char *plainText, int32_t plainTextSize, unsigned char *cipherText, int32_t cipherTextLen) { mbedtls_cipher_context_t ctx; @@ -73,10 +72,9 @@ int32_t DmAdapterCrypto::MbedAesGcmEncrypt(AesGcmCipherKey *cipherKey, const uns mbedtls_cipher_auth_encrypt_ext(&ctx, cipherKey->iv, GCM_IV_LEN, NULL, 0, plainText, plainTextSize, cipherText, cipherTextLen, &olen, TAG_LEN); mbedtls_cipher_free(&ctx); - return DM_OK; } -int32_t DmAdapterCrypto::MbedAesGcmDecrypt(AesGcmCipherKey *cipherKey, const unsigned char *cipherText, +void DmAdapterCrypto::MbedAesGcmDecrypt(AesGcmCipherKey *cipherKey, const unsigned char *cipherText, int32_t cipherTextSize, unsigned char *plain, int32_t plainLen) { mbedtls_cipher_context_t ctx; @@ -92,7 +90,6 @@ int32_t DmAdapterCrypto::MbedAesGcmDecrypt(AesGcmCipherKey *cipherKey, const uns LOGI("MbedAesGcmDEcrypt result :%d", ret); } mbedtls_cipher_free(&ctx); - return DM_OK; } }; // namespace DistributeHardware }; // namespace OHOS \ No newline at end of file diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 9c0c5ff20c759a87d28f29b4e44a03fb5527228c..d278923aaee5a3d008c7c1cdded8eb62bcdd1599 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -14,7 +14,6 @@ */ #include "dm_anonymous.h" -#include "dm_constants.h" #include "dm_log.h" namespace OHOS { diff --git a/common/src/dm_error_message.cpp b/common/src/dm_error_message.cpp index 9dcd0c022895033b139060f1cb29489239af542d..8cf81bdfa3cbf9e7917dbdcdc2eaeae6e43de07c 100644 --- a/common/src/dm_error_message.cpp +++ b/common/src/dm_error_message.cpp @@ -24,7 +24,7 @@ typedef struct ERROR_INFO { std::string errMsg; } ERROR_INFO; -static ERROR_INFO g_errorMessages[] = { +ERROR_INFO g_errorMessages[] = { {ERR_DM_FAILED, "dm process execution failed."}, {ERR_DM_TIME_OUT, "dm process execution timeout."}, {ERR_DM_NOT_INIT, "dm service is not initialized, please try again later."}, diff --git a/common/src/dm_log.cpp b/common/src/dm_log.cpp index 2abd410c6bbe2daf5dd009fcaa5b3310a47f29b6..82aee68ac65a240278de314fa01129165d457b93 100644 --- a/common/src/dm_log.cpp +++ b/common/src/dm_log.cpp @@ -15,9 +15,8 @@ #include "dm_log.h" -#include "dm_constants.h" #include "securec.h" - +#include #ifdef HI_LOG_ENABLE #include "hilog/log.h" #else diff --git a/common/src/dm_softbus_adapter_crypto.cpp b/common/src/dm_softbus_adapter_crypto.cpp index 490be92dec03781b3356f447e79121abfc328848..29162900f13460702ecea9f3d10d0ba8faa90b6a 100644 --- a/common/src/dm_softbus_adapter_crypto.cpp +++ b/common/src/dm_softbus_adapter_crypto.cpp @@ -15,7 +15,6 @@ #include "dm_softbus_adapter_crypto.h" -#include "dm_constants.h" #include "dm_log.h" #include "md.h" #include "securec.h" @@ -32,7 +31,9 @@ constexpr int HEXIFY_UNIT_LEN = 2; constexpr int HEX_DIGIT_MAX_NUM = 16; constexpr int DEC_MAX_NUM = 10; constexpr int HEX_MAX_BIT_NUM = 4; - +constexpr int ERR_DM_INPUT_PARA_INVALID = -20006; +constexpr int DM_OK = 0; +constexpr int ERR_DM_FAILED = -20000; #define HEXIFY_LEN(len) ((len) * HEXIFY_UNIT_LEN + 1) } // namespace diff --git a/common/src/ipc/standard/ipc_cmd_register.cpp b/common/src/ipc/standard/ipc_cmd_register.cpp index 6aa7d28282517c17ccfc6ad5a8943f974af26872..26d19c6f1e9f560ff7bd59e0cf6fa78931df86af 100644 --- a/common/src/ipc/standard/ipc_cmd_register.cpp +++ b/common/src/ipc/standard/ipc_cmd_register.cpp @@ -18,7 +18,6 @@ #include // for pair #include "device_manager_ipc_interface_code.h" -#include "dm_constants.h" #include "dm_log.h" #include "ipc_def.h" namespace OHOS { class MessageParcel; } @@ -26,6 +25,10 @@ namespace OHOS { class MessageParcel; } namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(IpcCmdRegister); +constexpr int32_t DM_OK = 0; +constexpr int32_t ERR_DM_INPUT_PARA_INVALID = -20006; +constexpr int32_t ERR_DM_UNSUPPORTED_IPC_COMMAND = -20015; +constexpr int32_t ERR_DM_POINT_NULL = -20005; int32_t IpcCmdRegister::SetRequest(int32_t cmdCode, std::shared_ptr pBaseReq, MessageParcel &data) { diff --git a/radar/include/dm_radar_helper.h b/radar/include/dm_radar_helper.h index 20964b86fea164278d61e32b69e524158cbb66cd..28950605a2050b38ce89bde3cd759dbce8de35a6 100644 --- a/radar/include/dm_radar_helper.h +++ b/radar/include/dm_radar_helper.h @@ -27,14 +27,6 @@ namespace OHOS { namespace DistributedHardware { -const std::string ORGPKGNAME = "deviceManager"; -const std::string SOFTBUSNAME = "dsoftbus"; -const std::string HICHAINNAME = "hichain"; -const std::string DM_DISCOVER_BEHAVIOR = "DM_DISCOVER_BEHAVIOR"; -const std::string DM_AUTHCATION_BEHAVIOR = "DM_AUTHCATION_BEHAVIOR"; -constexpr int32_t SUBSYS_DISTRIBUTEDHARDWARE_DM = 204; -constexpr int32_t INVALID_UDID_LENGTH = 10; -constexpr int32_t SUBSTR_UDID_LENGTH = 5; enum class BizScene : int32_t { DM_DISCOVER = 0x1, DM_AUTHCATION = 0x2, diff --git a/radar/src/dm_radar_helper.cpp b/radar/src/dm_radar_helper.cpp index bae04984e2552a726672ff7ce5059ae4e92dfe43..c4114ec225ebb18e363d84a86f5b07b90e716fec 100644 --- a/radar/src/dm_radar_helper.cpp +++ b/radar/src/dm_radar_helper.cpp @@ -31,6 +31,14 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(DmRadarHelper); +const std::string ORGPKGNAME = "deviceManager"; +const std::string SOFTBUSNAME = "dsoftbus"; +const std::string HICHAINNAME = "hichain"; +const std::string DM_DISCOVER_BEHAVIOR = "DM_DISCOVER_BEHAVIOR"; +const std::string DM_AUTHCATION_BEHAVIOR = "DM_AUTHCATION_BEHAVIOR"; +constexpr int32_t SUBSYS_DISTRIBUTEDHARDWARE_DM = 204; +constexpr int32_t INVALID_UDID_LENGTH = 10; +constexpr int32_t SUBSTR_UDID_LENGTH = 5; bool DmRadarHelper::ReportDiscoverRegCallback(struct RadarInfo &info) { int32_t res = DM_OK; diff --git a/radar/src/lite/dm_radar_helper.cpp b/radar/src/lite/dm_radar_helper.cpp index 7a249b23a1c4fb230f15e6d943e93bc077d63dc5..a2494ebd699e7f737beb80f3ece5936fb1c61682 100644 --- a/radar/src/lite/dm_radar_helper.cpp +++ b/radar/src/lite/dm_radar_helper.cpp @@ -27,6 +27,9 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(DmRadarHelper); +constexpr int32_t SUBSYS_DISTRIBUTEDHARDWARE_DM = 204; +constexpr int32_t INVALID_UDID_LENGTH = 10; +constexpr int32_t SUBSTR_UDID_LENGTH = 5; bool DmRadarHelper::ReportDiscoverRegCallback(struct RadarInfo &info) { return true; diff --git a/services/implementation/include/dependency/softbus/softbus_session.h b/services/implementation/include/dependency/softbus/softbus_session.h index 159e424a463f64d2c427f729de90973c80156660..a118f2719128824dbe79ce4dcdf6749800e372ab 100644 --- a/services/implementation/include/dependency/softbus/softbus_session.h +++ b/services/implementation/include/dependency/softbus/softbus_session.h @@ -34,11 +34,11 @@ public: static int OnSessionOpened(int sessionId, int result); static void OnSessionClosed(int sessionId); static void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen); - static void Encrypt(char* plainText, char* cipherText); - static void Decrypt(char* cipherText, unsigned int cipherTextLen, char* plainText); static void GetRealMessage(const void* data, unsigned int dataLen, std::string& message); static void OnUnbindSessionOpened(int sessionId, int result); static AesGcmCipherKey GetSessionKeyAndIv(); + static void Encrypt(char* plainText, char* cipherText); + static void Decrypt(char* cipherText, unsigned int cipherTextLen, char* plainText); public: SoftbusSession(); @@ -86,7 +86,6 @@ public: */ int32_t GetPeerDeviceId(int32_t sessionId, std::string &peerDevId); int32_t OpenUnbindSession(const std::string &netWorkId); - int32_t SendHeartbeatData(int32_t sessionId, std::string &message); private: diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 5d224f894c2bf7ac3383ca8193daa3dcf071a380..fd3bde1bb41b505163dad03fecc94cf58738a968 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -256,7 +256,7 @@ int32_t DmAuthManager::UnAuthenticateDevice(const std::string &pkgName, const st GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); struct RadarInfo info = { .funcName = "UnAuthenticateDevice", - .toCallPkg = HICHAINNAME, + .toCallPkg = "hichain", .stageRes = static_cast(StageRes::STAGE_SUCC), .bizState = static_cast(BizState::BIZ_STATE_START), .isTrust = static_cast(TrustStatus::NOT_TRUST), diff --git a/services/implementation/src/dependency/hichain/hichain_connector.cpp b/services/implementation/src/dependency/hichain/hichain_connector.cpp index d594da265b1ca05b04e92e0eee47a1f10270044b..0479c78c9ba5dbd2cd2e09b1ae180aaae5756ac9 100644 --- a/services/implementation/src/dependency/hichain/hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_connector.cpp @@ -157,7 +157,7 @@ int32_t HiChainConnector::CreateGroup(int64_t requestId, const std::string &grou int32_t ret = deviceGroupManager_->createGroup(userId, requestId, DM_PKG_NAME, jsonObj.dump().c_str()); struct RadarInfo info = { .funcName = "CreateGroup", - .toCallPkg = HICHAINNAME, + .toCallPkg = "hichain", .stageRes = (ret != 0) ? static_cast(StageRes::STAGE_FAIL) : static_cast(StageRes::STAGE_IDLE), .bizState = (ret != 0) ? diff --git a/services/implementation/src/dependency/softbus/softbus_connector.cpp b/services/implementation/src/dependency/softbus/softbus_connector.cpp index bc17ea342064e30f0faaaea1acc0cb367909ff1d..431d2ed8055462913770daaa0a3f9115d659a51e 100644 --- a/services/implementation/src/dependency/softbus/softbus_connector.cpp +++ b/services/implementation/src/dependency/softbus/softbus_connector.cpp @@ -170,7 +170,7 @@ int32_t SoftbusConnector::StartDiscovery(const DmSubscribeInfo &dmSubscribeInfo) int32_t ret = ::RefreshLNN(DM_PKG_NAME, &subscribeInfo, &softbusDiscoveryCallback_); struct RadarInfo info = { .funcName = "StartDiscovery", - .toCallPkg = SOFTBUSNAME, + .toCallPkg = "dsoftbus", .stageRes = (ret == DM_OK) ? static_cast(StageRes::STAGE_IDLE) : static_cast(StageRes::STAGE_FAIL), .bizState = (ret == DM_OK) ? @@ -204,7 +204,7 @@ int32_t SoftbusConnector::StartDiscovery(const uint16_t subscribeId) int32_t ret = ::RefreshLNN(DM_PKG_NAME, &subscribeInfo, &softbusDiscoveryByIdCallback_); struct RadarInfo info = { .funcName = "StartDiscovery", - .toCallPkg = SOFTBUSNAME, + .toCallPkg = "dsoftbus", .stageRes = (ret == DM_OK) ? static_cast(StageRes::STAGE_IDLE) : static_cast(StageRes::STAGE_FAIL), .bizState = (ret == DM_OK) ? @@ -228,7 +228,7 @@ int32_t SoftbusConnector::StopDiscovery(uint16_t subscribeId) int32_t ret = ::StopRefreshLNN(DM_PKG_NAME, subscribeId); struct RadarInfo info = { .funcName = "StopDiscovery", - .hostName = SOFTBUSNAME, + .hostName = "dsoftbus", .stageRes = (ret == DM_OK) ? static_cast(StageRes::STAGE_CANCEL) : static_cast(StageRes::STAGE_FAIL), .bizState = (ret == DM_OK) ? diff --git a/services/service/include/device_manager_service.h b/services/service/include/device_manager_service.h index 35ec0e50daa859d965a4d7a7a8f8951914078b0c..49ef6afd3d973441984eef08b3313106910778cc 100644 --- a/services/service/include/device_manager_service.h +++ b/services/service/include/device_manager_service.h @@ -31,7 +31,6 @@ #include "idevice_manager_service_impl.h" #include "i_dm_service_impl_ext.h" #include "single_instance.h" -#include "softbus_listener.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/service/include/discovery/discovery_filter.h b/services/service/include/discovery/discovery_filter.h index b216c0297a9d26ec856f2138870d8cc50961f1c2..05e920db8cd1029b9045760c26a5a7595cc5098f 100644 --- a/services/service/include/discovery/discovery_filter.h +++ b/services/service/include/discovery/discovery_filter.h @@ -19,7 +19,7 @@ #include #include -#include "nlohmann/json.hpp" +#include "dm_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/service/include/softbus/softbus_adapter.h b/services/service/include/softbus/softbus_adapter.h index 3850ecb28e91fb5a82e1719eebef5fa8db72b834..0f88d24cc1064c1910a893b3ce61aa03cf3554f8 100644 --- a/services/service/include/softbus/softbus_adapter.h +++ b/services/service/include/softbus/softbus_adapter.h @@ -22,10 +22,6 @@ #include "session.h" #include "single_instance.h" - -#include "dm_constants.h" -#include "dm_device_info.h" -#include "dm_log.h" namespace OHOS { namespace DistributedHardware { class SoftbusAdapter { diff --git a/services/service/src/advertise/advertise_manager.cpp b/services/service/src/advertise/advertise_manager.cpp index b578e6a601331d04e5f3499c935946e4eb033fb3..174f651be6f0c27c5df227d8e6798f34da6bf95d 100644 --- a/services/service/src/advertise/advertise_manager.cpp +++ b/services/service/src/advertise/advertise_manager.cpp @@ -15,7 +15,6 @@ #include "advertise_manager.h" -#include "dm_anonymous.h" #include "dm_constants.h" #include "dm_log.h" #include "dm_publish_info.h" diff --git a/services/service/src/discovery/discovery_filter.cpp b/services/service/src/discovery/discovery_filter.cpp index 1911ffec3d9596f6fe07196626e0b7237071ae45..1620855e246ab1436dfbe9455a3ec9f7845b583b 100644 --- a/services/service/src/discovery/discovery_filter.cpp +++ b/services/service/src/discovery/discovery_filter.cpp @@ -15,11 +15,9 @@ #include "discovery_filter.h" -#include "dm_anonymous.h" -#include "dm_constants.h" #include "dm_device_info.h" -#include "dm_log.h" #include "nlohmann/json.hpp" +#include "dm_log.h" namespace OHOS { namespace DistributedHardware { @@ -27,7 +25,8 @@ const std::string FILTERS_KEY = "filters"; const std::string FILTER_OP_KEY = "filter_op"; const std::string FILTERS_TYPE_OR = "OR"; const std::string FILTERS_TYPE_AND = "AND"; - +const int32_t DM_OK = 0; +const int32_t ERR_DM_INPUT_PARA_INVALID = -20006; enum DmDiscoveryDeviceFilter { DM_INVALID_DEVICE = 0, DM_VALID_DEVICE = 1, diff --git a/services/service/src/discovery/discovery_manager.cpp b/services/service/src/discovery/discovery_manager.cpp index ea1ae1de84466ad7d4b64565411a735c6ec7a1fc..12c08697e4ea4fe8c0b5276f9435fe13d1606fee 100644 --- a/services/service/src/discovery/discovery_manager.cpp +++ b/services/service/src/discovery/discovery_manager.cpp @@ -18,12 +18,9 @@ #include #include -#include "discovery_filter.h" #include "dm_anonymous.h" #include "dm_constants.h" -#include "dm_log.h" #include "parameter.h" -#include "dm_radar_helper.h" namespace OHOS { namespace DistributedHardware { const int32_t DISCOVERY_TIMEOUT = 120; diff --git a/services/service/src/permission/standard/permission_manager.cpp b/services/service/src/permission/standard/permission_manager.cpp index b55a52094b0307c4e631127616e425c9e06f02e5..4f1e41ecd231b22c5c3c0f8f7c5f6e04c4ca7827 100644 --- a/services/service/src/permission/standard/permission_manager.cpp +++ b/services/service/src/permission/standard/permission_manager.cpp @@ -17,7 +17,6 @@ #include "accesstoken_kit.h" #include "access_token.h" -#include "dm_constants.h" #include "dm_log.h" #include "hap_token_info.h" #include "ipc_skeleton.h" @@ -33,7 +32,9 @@ IMPLEMENT_SINGLE_INSTANCE(PermissionManager); namespace { constexpr const char* DM_SERVICE_ACCESS_PERMISSION = "ohos.permission.ACCESS_SERVICE_DM"; constexpr const char* DM_SERVICE_ACCESS_NEWPERMISSION = "ohos.permission.DISTRIBUTED_DATASYNC"; - +constexpr int32_t DM_OK = 0; +constexpr int32_t ERR_DM_FAILED = -20000; +constexpr int32_t PKG_NAME_SIZE_MAX = 256; #define AUTH_CODE_WHITE_LIST_NUM (2) constexpr const static char g_authCodeWhiteList[AUTH_CODE_WHITE_LIST_NUM][PKG_NAME_SIZE_MAX] = { "com.huawei.msdp.hmringgenerator", diff --git a/services/service/src/pinholder/pin_holder.cpp b/services/service/src/pinholder/pin_holder.cpp index 8b8afce791a982a86bac783049ae7d27132916c6..ad29114a8988d83b32b59bb8bc0aa3992333a884 100644 --- a/services/service/src/pinholder/pin_holder.cpp +++ b/services/service/src/pinholder/pin_holder.cpp @@ -16,11 +16,9 @@ #include "pin_holder.h" #include "dm_anonymous.h" -#include "dm_constants.h" #include "dm_log.h" #include "dm_softbus_adapter_crypto.h" #include "nlohmann/json.hpp" -#include "parameter.h" namespace OHOS { namespace DistributedHardware { @@ -40,6 +38,14 @@ constexpr int32_t PIN_HOLDER_SESSION_CREATE_TIMEOUT = 60; constexpr const char* TAG_PIN_TYPE = "PIN_TYPE"; constexpr const char* TAG_PAYLOAD = "PAYLOAD"; constexpr const char* TAG_REPLY = "REPLY"; + +constexpr int32_t DM_OK = 0; +constexpr int32_t ERR_DM_FAILED = -20000; +constexpr int32_t ERR_DM_AUTH_OPEN_SESSION_FAILED = -20020; +constexpr const char* TAG_MSG_TYPE = "MSG_TYPE"; +constexpr const char* DM_CONNECTION_DISCONNECTED = "DM_CONNECTION_DISCONNECTED"; +constexpr int32_t DEVICE_UUID_LENGTH = 65; +constexpr int32_t ERR_DM_INPUT_PARA_INVALID = -20006; PinHolder::PinHolder(std::shared_ptr listener): listener_(listener) { if (session_ == nullptr) { diff --git a/services/service/src/pinholder/pin_holder_session.cpp b/services/service/src/pinholder/pin_holder_session.cpp index 5d4a668e9ec06b3062570ef00581d1beaf96fcef..aa736a75238b558138108727bf495e70c75b867d 100644 --- a/services/service/src/pinholder/pin_holder_session.cpp +++ b/services/service/src/pinholder/pin_holder_session.cpp @@ -16,7 +16,6 @@ #include "pin_holder_session.h" #include "dm_anonymous.h" -#include "dm_constants.h" #include "dm_log.h" #include "dm_softbus_adapter_crypto.h" #include "nlohmann/json.hpp" @@ -24,6 +23,10 @@ namespace OHOS { namespace DistributedHardware { std::shared_ptr PinHolderSession::pinholderSessionCallback_ = nullptr; +constexpr int32_t DM_OK = 0; +constexpr int32_t ERR_DM_FAILED = -20000; +constexpr const char* TAG_MSG_TYPE = "MSG_TYPE"; +constexpr const char* DM_PIN_HOLDER_SESSION_NAME = "ohos.distributedhardware.devicemanager.pinholder"; PinHolderSession::PinHolderSession() { LOGD("PinHolderSession constructor."); diff --git a/services/service/src/softbus/softbus_adapte.cpp b/services/service/src/softbus/softbus_adapter.cpp similarity index 99% rename from services/service/src/softbus/softbus_adapte.cpp rename to services/service/src/softbus/softbus_adapter.cpp index cb3022e704c934bdd18510d10958232ddb3da9a8..2f47841791f13f4231fa5045b04529c633c64807 100644 --- a/services/service/src/softbus/softbus_adapte.cpp +++ b/services/service/src/softbus/softbus_adapter.cpp @@ -14,7 +14,7 @@ */ #include "softbus_adapter.h" - +#include "dm_log.h" #include #include diff --git a/services/service/src/softbus/softbus_listener.cpp b/services/service/src/softbus/softbus_listener.cpp index a06b5de6bf36d3e1dd1632d2d24ee5455f2486c8..63b7c8f08fd8df5f9152205e1665457c388c0869 100644 --- a/services/service/src/softbus/softbus_listener.cpp +++ b/services/service/src/softbus/softbus_listener.cpp @@ -32,7 +32,7 @@ #include "parameter.h" #include "system_ability_definition.h" #include "dm_softbus_adapter_crypto.h" -#include "softbus_adapte.cpp" +#include "softbus_adapter.cpp" #include "softbus_common.h" #include "softbus_bus_center.h" #include "dm_radar_helper.h" @@ -540,7 +540,7 @@ int32_t SoftbusListener::RefreshSoftbusLNN(const char *pkgName, const DmSubscrib int32_t ret = ::RefreshLNN(pkgName, &subscribeInfo, &softbusRefreshCallback_); struct RadarInfo info = { .funcName = "RefreshSoftbusLNN", - .toCallPkg = SOFTBUSNAME, + .toCallPkg = "dsoftbus", .stageRes = (ret == DM_OK) ? static_cast(StageRes::STAGE_IDLE) : static_cast(StageRes::STAGE_FAIL), .bizState = (ret == DM_OK) ? @@ -594,7 +594,7 @@ int32_t SoftbusListener::StopRefreshSoftbusLNN(uint16_t subscribeId) int32_t ret = ::StopRefreshLNN(DM_PKG_NAME, subscribeId); struct RadarInfo info = { .funcName = "StopRefreshSoftbusLNN", - .hostName = SOFTBUSNAME, + .hostName = "dsoftbus", .stageRes = (ret == DM_OK) ? static_cast(StageRes::STAGE_CANCEL) : static_cast(StageRes::STAGE_FAIL), .bizState = (ret == DM_OK) ? diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 411e5cc025d185b914c7ba22450c32a7f005d3b4..28402d9ec156d3b0ca4032c58ab753a1b6d8bb17 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -356,6 +356,7 @@ ohos_unittest("UTTest_dm_anonymous") { sources = [ "${common_path}/src/dm_anonymous.cpp", + "${common_path}/src/dm_error_message.cpp", "${devicemanager_path}/test/commonunittest/UTTest_dm_anonymous.cpp", ] diff --git a/utils/BUILD.gn b/utils/BUILD.gn index f10468c219d4f45bafc764b6c665b0b60d35f1f6..babb1a8c3a688fac6cd269043e3353ce40c99777 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -78,12 +78,6 @@ if (defined(ohos_lite)) { "include/appInfo/standard", "include/timer", "${common_path}/include", - "${common_path}/include/ipc", - "${common_path}/include/ipc/model", - "${common_path}/include/ipc/standard", - "${common_path}/include/dfx", - "${common_path}/include/dfx/standard", - "${innerkits_path}/native_cpp/include", "//third_party/mbedtls/include/mbedtls", "//third_party/json/include", ] @@ -102,13 +96,7 @@ if (defined(ohos_lite)) { } sources = [ - "${common_path}/src/dfx/standard/dm_hidumper.cpp", - "${common_path}/src/dfx/standard/dm_hisysevent.cpp", - "${common_path}/src/dfx/standard/dm_hitrace.cpp", - "${common_path}/src/dm_anonymous.cpp", - "${common_path}/src/dm_error_message.cpp", "${common_path}/src/dm_log.cpp", - "${common_path}/src/ipc/standard/ipc_cmd_register.cpp", "src/appInfo/standard/app_manager.cpp", "src/crypto/dm_crypto.cpp", "src/dm_random.cpp", @@ -133,13 +121,10 @@ if (defined(ohos_lite)) { ] external_deps = [ - "ability_base:want", "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", "hilog:libhilog", - "hisysevent:libhisysevent", - "hitrace:hitrace_meter", "ipc:ipc_core", "ipc:ipc_single", "samgr:samgr_proxy", diff --git a/utils/include/crypto/dm_crypto.h b/utils/include/crypto/dm_crypto.h index 084a2116db39a7bd8c537999f913dc50eaa157b2..b718cc87f401c27e565455d61b5bcbd2d5f90961 100644 --- a/utils/include/crypto/dm_crypto.h +++ b/utils/include/crypto/dm_crypto.h @@ -16,7 +16,6 @@ #ifndef OHOS_DM_CRYPTO_H #define OHOS_DM_CRYPTO_H #include -#include namespace OHOS { namespace DistributedHardware { diff --git a/utils/src/appInfo/standard/app_manager.cpp b/utils/src/appInfo/standard/app_manager.cpp index 8c0333083e57f093037bd01968fad1d5f6120453..4ca43548be9581a2a086e3866eb95e35f28666a6 100644 --- a/utils/src/appInfo/standard/app_manager.cpp +++ b/utils/src/appInfo/standard/app_manager.cpp @@ -16,7 +16,6 @@ #include "app_manager.h" #include "accesstoken_kit.h" -#include "dm_log.h" #include "ipc_skeleton.h" using namespace OHOS::Security::AccessToken; @@ -28,14 +27,12 @@ IMPLEMENT_SINGLE_INSTANCE(AppManager); const std::string AppManager::GetAppId() { AccessTokenID tokenId = IPCSkeleton::GetCallingTokenID(); - LOGI("AppManager::tokenCaller ID == %d", tokenId); if (AccessTokenKit::GetTokenTypeFlag(tokenId) != TOKEN_HAP) { return ""; } HapTokenInfo tokenInfo; auto result = AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo); if (result != RET_SUCCESS) { - LOGE("GetHapTokenInfo, tokenId = %d, result = %d, ", tokenId, result); return ""; } diff --git a/utils/src/crypto/dm_crypto.cpp b/utils/src/crypto/dm_crypto.cpp index 1a2c7f1cb28048deeecc973337825e978c6fce10..f512556933c9e15854b3260755d3f04e4055052f 100644 --- a/utils/src/crypto/dm_crypto.cpp +++ b/utils/src/crypto/dm_crypto.cpp @@ -15,7 +15,6 @@ #include "dm_crypto.h" #include -#include #include #include "openssl/sha.h" diff --git a/utils/src/dm_random.cpp b/utils/src/dm_random.cpp index e6a4b2f6916c6ce24026e35a65329104e3504d76..913138632c4ca8677caea21c77ba518d2af79b92 100644 --- a/utils/src/dm_random.cpp +++ b/utils/src/dm_random.cpp @@ -17,7 +17,6 @@ #include -#include "dm_constants.h" #include "mbedtls/ctr_drbg.h" #include "mbedtls/entropy.h" @@ -27,6 +26,8 @@ namespace OHOS { namespace DistributedHardware { +constexpr uint32_t ERR_DM_FAILED = -20000; +constexpr int32_t DM_OK = 0; int32_t GenRandInt(int32_t randMin, int32_t randMax) { #if defined(__LITEOS_M__) diff --git a/utils/src/fwkload/lite/dm_distributed_hardware_load.cpp b/utils/src/fwkload/lite/dm_distributed_hardware_load.cpp index 1662a20d5496edf47fb07ce463ca0935963afae5..c4832c5f8a4fb67b99b9c939b00ba1144566087c 100644 --- a/utils/src/fwkload/lite/dm_distributed_hardware_load.cpp +++ b/utils/src/fwkload/lite/dm_distributed_hardware_load.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ -#include "dm_constants.h" #include "dm_distributed_hardware_load.h" namespace OHOS { diff --git a/utils/src/fwkload/standard/dm_distributed_hardware_load.cpp b/utils/src/fwkload/standard/dm_distributed_hardware_load.cpp index cb15b0833e04cc65345a8adae0f8db2249daa7b6..330f4e22116a1e5e081a2d32982f2de0a6816680 100644 --- a/utils/src/fwkload/standard/dm_distributed_hardware_load.cpp +++ b/utils/src/fwkload/standard/dm_distributed_hardware_load.cpp @@ -15,7 +15,6 @@ #include "dm_distributed_hardware_load.h" -#include "dm_constants.h" #include "dm_log.h" #include "if_system_ability_manager.h" // for ISystemAbilityManager #include "iservice_registry.h" // for SystemAbilityManagerClient @@ -24,8 +23,8 @@ namespace OHOS { namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(DmDistributedHardwareLoad); -const uint32_t MAX_LOAD_VALUE = 3; - +constexpr uint32_t MAX_LOAD_VALUE = 3; +constexpr int32_t DM_OK = 0; void DmDistributedHardwareLoad::LoadDistributedHardwareFwk(void) { LOGI("enter DmDistributedHardwareLoad::LoadDistributedHardwareFwk"); diff --git a/utils/src/timer/dm_timer.cpp b/utils/src/timer/dm_timer.cpp index 9082aba895a6f1be712b3110ea34b23d9830f12e..72a90c824e61ba8da42a6987b5c3dffd0b966e34 100644 --- a/utils/src/timer/dm_timer.cpp +++ b/utils/src/timer/dm_timer.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ -#include "dm_constants.h" #include "dm_log.h" #include "dm_timer.h" @@ -24,6 +23,8 @@ namespace OHOS { namespace DistributedHardware { constexpr const char* TIMER_RUNNING = "TimerRunning"; +constexpr int32_t ERR_DM_INPUT_PARA_INVALID = -20006; +constexpr int32_t DM_OK = 0; Timer::Timer(std::string name, int32_t time, TimerCallback callback) : timerName_(name), expire_(steadyClock::now()), state_(true), timeOut_(time), callback_(callback) {};