From 4ef75d0678a76ede9fa76ee0864969b2db2dcfef Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Sat, 27 Jan 2024 14:27:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?DM=E5=BC=80=E6=9C=BA=E5=86=85=E5=AD=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- common/include/dm_adapter_crypto.h | 4 ++-- common/src/dfx/standard/dm_hidumper.cpp | 3 ++- common/src/dfx/standard/dm_hisysevent.cpp | 2 +- common/src/dm_adapter_crypto.cpp | 7 ++----- common/src/dm_anonymous.cpp | 1 - common/src/dm_error_message.cpp | 2 +- common/src/dm_log.cpp | 3 +-- common/src/dm_softbus_adapter_crypto.cpp | 5 +++-- common/src/ipc/standard/ipc_cmd_register.cpp | 5 ++++- radar/include/dm_radar_helper.h | 8 -------- radar/src/dm_radar_helper.cpp | 8 ++++++++ .../include/dependency/softbus/softbus_session.h | 5 ++--- .../src/authentication/dm_auth_manager.cpp | 2 +- .../src/dependency/hichain/hichain_connector.cpp | 2 +- .../src/dependency/softbus/softbus_connector.cpp | 6 +++--- services/service/include/device_manager_service.h | 1 - .../service/include/discovery/discovery_filter.h | 2 +- .../service/include/softbus/softbus_adapter.h | 4 ---- .../service/src/advertise/advertise_manager.cpp | 1 - .../service/src/discovery/discovery_filter.cpp | 7 +++---- .../service/src/discovery/discovery_manager.cpp | 4 +--- .../permission/standard/permission_manager.cpp | 5 +++-- services/service/src/pinholder/pin_holder.cpp | 10 ++++++++-- .../service/src/pinholder/pin_holder_session.cpp | 5 ++++- .../{softbus_adapte.cpp => softbus_adapter.cpp} | 2 +- services/service/src/softbus/softbus_listener.cpp | 6 +++--- test/unittest/BUILD.gn | 1 + utils/BUILD.gn | 15 --------------- utils/include/crypto/dm_crypto.h | 1 - utils/src/appInfo/standard/app_manager.cpp | 3 --- utils/src/crypto/dm_crypto.cpp | 1 - utils/src/dm_random.cpp | 3 ++- .../fwkload/lite/dm_distributed_hardware_load.cpp | 1 - .../standard/dm_distributed_hardware_load.cpp | 5 ++--- utils/src/timer/dm_timer.cpp | 3 ++- 35 files changed, 62 insertions(+), 81 deletions(-) rename services/service/src/softbus/{softbus_adapte.cpp => softbus_adapter.cpp} (99%) diff --git a/common/include/dm_adapter_crypto.h b/common/include/dm_adapter_crypto.h index ecc375785..621a338d1 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 74af394b8..eeb2101b9 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 b2e71a090..371896a16 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 d66860d49..a8fe53d78 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 9c0c5ff20..d278923aa 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 9dcd0c022..8cf81bdfa 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 2abd410c6..82aee68ac 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 490be92de..29162900f 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 6aa7d2828..26d19c6f1 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 20964b86f..28950605a 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 bae04984e..c4114ec22 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/services/implementation/include/dependency/softbus/softbus_session.h b/services/implementation/include/dependency/softbus/softbus_session.h index 159e424a4..9a65c885f 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 5d224f894..fd3bde1bb 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 d594da265..0479c78c9 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 bc17ea342..431d2ed80 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 35ec0e50d..49ef6afd3 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 b216c0297..05e920db8 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 3850ecb28..0f88d24cc 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 b578e6a60..174f651be 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 1911ffec3..1620855e2 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 ea1ae1de8..89a462ce2 100644 --- a/services/service/src/discovery/discovery_manager.cpp +++ b/services/service/src/discovery/discovery_manager.cpp @@ -18,12 +18,10 @@ #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" +#include "dm_log.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 b55a52094..4f1e41ecd 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 8b8afce79..ad29114a8 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 5d4a668e9..aa736a752 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 cb3022e70..2f4784179 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 a06b5de6b..63b7c8f08 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 411e5cc02..28402d9ec 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 f10468c21..babb1a8c3 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 084a2116d..b718cc87f 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 8c0333083..4ca43548b 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 1a2c7f1cb..f51255693 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 e6a4b2f69..913138632 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 1662a20d5..c4832c5f8 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 cb15b0833..330f4e221 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 9082aba89..72a90c824 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) {}; -- Gitee From 5d25f76cab6caaa075fbcba37c909f05163b5be4 Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Sat, 27 Jan 2024 15:55:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?DM=E5=BC=80=E6=9C=BA=E5=86=85=E5=AD=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- radar/src/lite/dm_radar_helper.cpp | 3 +++ .../include/dependency/softbus/softbus_session.h | 2 +- services/service/src/discovery/discovery_manager.cpp | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/radar/src/lite/dm_radar_helper.cpp b/radar/src/lite/dm_radar_helper.cpp index 7a249b23a..a2494ebd6 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 9a65c885f..a118f2719 100644 --- a/services/implementation/include/dependency/softbus/softbus_session.h +++ b/services/implementation/include/dependency/softbus/softbus_session.h @@ -38,7 +38,7 @@ public: 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); + static void Decrypt(char* cipherText, unsigned int cipherTextLen, char* plainText); public: SoftbusSession(); diff --git a/services/service/src/discovery/discovery_manager.cpp b/services/service/src/discovery/discovery_manager.cpp index 89a462ce2..12c08697e 100644 --- a/services/service/src/discovery/discovery_manager.cpp +++ b/services/service/src/discovery/discovery_manager.cpp @@ -21,7 +21,6 @@ #include "dm_anonymous.h" #include "dm_constants.h" #include "parameter.h" -#include "dm_log.h" namespace OHOS { namespace DistributedHardware { const int32_t DISCOVERY_TIMEOUT = 120; -- Gitee