From 744e647dfe82fe594b082ec982c2c8c22864eecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E4=B8=8D=E5=87=BA=E5=88=AB=E5=90=8D?= Date: Sun, 12 Sep 2021 14:31:51 +0800 Subject: [PATCH 1/2] codestyle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 想不出别名 --- .../native_cpp/include/dm_app_image_info.h | 4 +- .../native_cpp/src/device_manager_impl.cpp | 2 +- .../src/ipc/lite/ipc_client_server_proxy.cpp | 2 +- .../src/notify/device_manager_notify.cpp | 2 +- .../kits/js/include/native_devicemanager_js.h | 8 +- .../kits/js/src/native_devicemanager_js.cpp | 79 ++++++++----------- .../include/auth/hichain_connector.h | 8 +- .../include/ipc/lite/ipc_server_listenermgr.h | 8 +- .../include/message/msg_request_auth.h | 24 +++--- .../src/auth/hichain_connector.cpp | 12 +-- .../src/ipc/lite/ipc_server_stub.cpp | 2 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 2 +- .../src/softbus/softbus_adapter.cpp | 4 +- utils/src/anonymous_string.cpp | 8 +- utils/src/cipher/encrypt_utils.cpp | 4 +- 15 files changed, 79 insertions(+), 90 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/include/dm_app_image_info.h b/interfaces/inner_kits/native_cpp/include/dm_app_image_info.h index d9d18c8b3..164bd5f4c 100644 --- a/interfaces/inner_kits/native_cpp/include/dm_app_image_info.h +++ b/interfaces/inner_kits/native_cpp/include/dm_app_image_info.h @@ -54,7 +54,7 @@ public: } } - DmAppImageInfo& operator= (const DmAppImageInfo &other) + DmAppImageInfo& operator=(const DmAppImageInfo &other) { if (this != &other) { SaveData(other.GetAppIcon(), other.GetAppIconLen(), other.GetAppThumbnail(), other.GetAppThumbnailLen()); @@ -63,7 +63,7 @@ public: } DmAppImageInfo(DmAppImageInfo&&) = delete; - DmAppImageInfo& operator= (DmAppImageInfo&&) = delete; + DmAppImageInfo& operator=(DmAppImageInfo&&) = delete; int32_t GetAppIconLen() const { 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 e2a39db6c..23f7ef2c6 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -280,7 +280,7 @@ int32_t DeviceManagerImpl::RegisterDeviceManagerFaCallback(std::string &packageN int32_t DeviceManagerImpl::UnRegisterDeviceManagerFaCallback(std::string &pkgName) { - DMLOG(DM_LOG_INFO, "DeviceManager::UnRegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str()); + DMLOG(DM_LOG_INFO, "DeviceManager::UnRegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str()); if (pkgName.empty()) { DMLOG(DM_LOG_ERROR, "Invalid para"); return DEVICEMANAGER_INVALID_VALUE; 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 922844c70..bfac66bf3 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 @@ -53,7 +53,7 @@ int32_t DMDeathCallback(const IpcContext *ctx, void *ipcMsg, IpcIo *data, void * return DEVICEMANAGER_OK; } -static int32_t SendCmdResultCb(IOwner owner, int code, IpcIo *reply) +static int32_t SendCmdResultCb(IOwner owner, int32_t code, IpcIo *reply) { (void)code; int32_t cmdCode = *(int32_t *)owner; diff --git a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index bf8961b57..4144e3ac6 100644 --- a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp @@ -283,7 +283,7 @@ void DeviceManagerNotify::OnCheckAuthResult(std::string &pkgName, std::string &d void DeviceManagerNotify::OnFaCall(std::string &pkgName, std::string ¶mJson) { - DMLOG(DM_LOG_INFO, "DeviceManager OnFaCallback pkgName:%s", pkgName.c_str()); + DMLOG(DM_LOG_INFO, "DeviceManager OnFaCallback pkgName:%s", pkgName.c_str()); std::lock_guard autoLock(lock_); if (dmFaCallback_.count(pkgName) == 0) { DMLOG(DM_LOG_ERROR, "DeviceManager DmFaCallback not register"); diff --git a/interfaces/kits/js/include/native_devicemanager_js.h b/interfaces/kits/js/include/native_devicemanager_js.h index c03fc4cd4..c232985c0 100644 --- a/interfaces/kits/js/include/native_devicemanager_js.h +++ b/interfaces/kits/js/include/native_devicemanager_js.h @@ -27,7 +27,7 @@ #include "nlohmann/json.hpp" #include "dm_device_info.h" -const int DM_NAPI_BUF_LENGTH = 256; +#define DM_NAPI_BUF_LENGTH (256) struct AsyncCallbackInfo { napi_env env = nullptr; @@ -149,15 +149,15 @@ public: static void ReleaseDmCallback(std::string &bundleName, std::string &eventType); static void DeviceInfoToJsArray(const napi_env &env, const std::vector& vecDevInfo, - const int idx, napi_value &arrayResult); + const int32_t idx, napi_value &arrayResult); static void DmAuthParamToJsAuthParam(const napi_env &env, const OHOS::DistributedHardware::DmAuthParam &authParam, napi_value ¶mResult); - static void SetValueInt32(const napi_env &env, const std::string &fieldStr, const int intValue, + static void SetValueInt32(const napi_env &env, const std::string &fieldStr, const int32_t intValue, napi_value &result); static void SetValueUtf8String(const napi_env &env, const std::string &fieldStr, const std::string &str, napi_value &result); static void JsObjectToString(const napi_env &env, const napi_value &object, - const std::string &fieldStr, char *dest, const int destLen); + const std::string &fieldStr, char *dest, const int32_t destLen); static void JsObjectToBool(const napi_env &env, const napi_value &object, const std::string &fieldStr, bool& fieldRef); static void JsObjectToInt(const napi_env &env, const napi_value &object, const std::string &fieldStr, diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index 3b7c40e87..9d00ded1e 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -40,13 +40,15 @@ const std::string DM_NAPI_EVENT_DEVICE_SERVICE_DIE = "serviceDie"; const std::string DEVICE_MANAGER_NAPI_CLASS_NAME = "DeviceManager"; -const int DM_NAPI_ARGS_ONE = 1; -const int DM_NAPI_ARGS_TWO = 2; -const int DM_NAPI_ARGS_THREE = 3; -const int DM_NAPI_SUB_ID_MAX = 65535; +const int32_t DM_NAPI_ARGS_ONE = 1; +const int32_t DM_NAPI_ARGS_TWO = 2; +const int32_t DM_NAPI_ARGS_THREE = 3; +const int32_t DM_NAPI_SUB_ID_MAX = 65535; -const int DM_AUTH_TYPE_PINCODE = 1; -const int DM_AUTH_DIRECTION_CLIENT = 1; +const int32_t DM_AUTH_TYPE_PINCODE = 1; +const int32_t DM_AUTH_DIRECTION_CLIENT = 1; + +const int32_t DM_NAPI_SUBSCRIBE_CAPABILITY_DDMP = 0; std::map g_deviceManagerMap; std::map> g_initCallbackMap; @@ -57,13 +59,9 @@ std::map> g_checkAuthCallb std::map> g_dmfaCallbackMap; } -enum DmNapiSubscribeCap { - DM_NAPI_SUBSCRIBE_CAPABILITY_DDMP = 0 -}; - napi_ref DeviceManagerNapi::sConstructor_ = nullptr; -AuthAsyncCallbackInfo DeviceManagerNapi::authAsyncCallbackInfo_ = {0}; -AuthAsyncCallbackInfo DeviceManagerNapi::verifyAsyncCallbackInfo_ = {0}; +AuthAsyncCallbackInfo DeviceManagerNapi::authAsyncCallbackInfo_; +AuthAsyncCallbackInfo DeviceManagerNapi::verifyAsyncCallbackInfo_; void DmNapiInitCallback::OnRemoteDied() { @@ -339,7 +337,7 @@ void DeviceManagerNapi::SetValueUtf8String(const napi_env &env, const std::strin napi_set_named_property(env, result, fieldStr.c_str(), value); } -void DeviceManagerNapi::SetValueInt32(const napi_env &env, const std::string &fieldStr, const int intValue, +void DeviceManagerNapi::SetValueInt32(const napi_env &env, const std::string &fieldStr, const int32_t intValue, napi_value &result) { napi_value value; @@ -349,7 +347,7 @@ void DeviceManagerNapi::SetValueInt32(const napi_env &env, const std::string &fi void DeviceManagerNapi::DeviceInfoToJsArray(const napi_env &env, const std::vector &vecDevInfo, - const int idx, napi_value &arrayResult) + const int32_t idx, napi_value &arrayResult) { napi_value result; napi_create_object(env, &result); @@ -416,7 +414,7 @@ void DeviceManagerNapi::DmAuthParamToJsAuthParamy(const napi_env &env, } void DeviceManagerNapi::JsObjectToString(const napi_env &env, const napi_value &object, - const std::string &fieldStr, char *dest, const int destLen) + const std::string &fieldStr, char *dest, const int32_t destLen) { bool hasProperty = false; NAPI_CALL_RETURN_VOID(env, napi_has_named_property(env, object, fieldStr.c_str(), &hasProperty)); @@ -463,7 +461,7 @@ std::string DeviceManagerNapi::JsObjectToString(const napi_env &env, const napi_ } void DeviceManagerNapi::JsObjectToInt(const napi_env &env, const napi_value &object, - const std::string &fieldStr, int &fieldRef) + const std::string &fieldStr, int32_t &fieldRef) { bool hasProperty = false; NAPI_CALL_RETURN_VOID(env, napi_has_named_property(env, object, fieldStr.c_str(), &hasProperty)); @@ -501,7 +499,7 @@ void DeviceManagerNapi::JsObjectToBool(const napi_env &env, const napi_value &ob int32_t DeviceManagerNapi::JsToDmSubscribeInfo(const napi_env &env, const napi_value &object, DmSubscribeInfo &info) { - int subscribeId = -1; + int32_t subscribeId = -1; JsObjectToInt(env, object, "subscribeId", subscribeId); if (subscribeId < 0 || subscribeId > DM_NAPI_SUB_ID_MAX) { DMLOG(DM_LOG_ERROR, "DeviceManagerNapi::JsToDmSubscribeInfo, subscribeId error, subscribeId: %d ", subscribeId); @@ -510,24 +508,24 @@ int32_t DeviceManagerNapi::JsToDmSubscribeInfo(const napi_env &env, const napi_v info.subscribeId = (uint16_t)subscribeId; - int mode = -1; + int32_t mode = -1; JsObjectToInt(env, object, "mode", mode); info.mode = (DmDiscoverMode)mode; - int medium = -1; + int32_t medium = -1; JsObjectToInt(env, object, "medium", medium); info.medium = (DmExchangeMedium)medium; - int freq = -1; + int32_t freq = -1; JsObjectToInt(env, object, "freq", freq); info.freq = (DmExchangeFreq)freq; JsObjectToBool(env, object, "isSameAccount", info.isSameAccount); JsObjectToBool(env, object, "isWakeRemote", info.isWakeRemote); - int capability = -1; + int32_t capability = -1; JsObjectToInt(env, object, "capability", capability); - if (capability == DmNapiSubscribeCap::DM_NAPI_SUBSCRIBE_CAPABILITY_DDMP) { + if (capability == DM_NAPI_SUBSCRIBE_CAPABILITY_DDMP) { (void)strncpy_s(info.capability, sizeof(info.capability), DM_CAPABILITY_OSD, strlen(DM_CAPABILITY_OSD)); } return 0; @@ -538,7 +536,7 @@ void DeviceManagerNapi::JsToDmDeviceInfo(const napi_env &env, const napi_value & { JsObjectToString(env, object, "deviceId", info.deviceId, sizeof(info.deviceId)); JsObjectToString(env, object, "deviceName", info.deviceName, sizeof(info.deviceName)); - int deviceType = -1; + int32_t deviceType = -1; JsObjectToInt(env, object, "deviceType", deviceType); info.deviceTypeId = (DMDeviceType)deviceType; } @@ -547,7 +545,7 @@ void DeviceManagerNapi::JsToDmAppImageInfoAndDmExtra(const napi_env &env, const DmAppImageInfo& appImageInfo, std::string &extra, int32_t &authType) { DMLOG(DM_LOG_INFO, "JsToDmAppImageInfoAndDmExtra in."); - int authTypeTemp = -1; + int32_t authTypeTemp = -1; JsObjectToInt(env, object, "authType", authTypeTemp); authType = authTypeTemp; @@ -634,7 +632,6 @@ void DeviceManagerNapi::JsToJsonObject(const napi_env &env, const napi_value &ob uint32_t jsProCount = 0; napi_get_property_names(env, jsonField, &jsProNameList); napi_get_array_length(env, jsProNameList, &jsProCount); - DMLOG(DM_LOG_INFO, "Property size=%d.", jsProCount); napi_value jsProName = nullptr; napi_value jsProValue = nullptr; @@ -645,15 +642,12 @@ void DeviceManagerNapi::JsToJsonObject(const napi_env &env, const napi_value &ob napi_typeof(env, jsProValue, &jsValueType); switch (jsValueType) { case napi_string: { - std::string natValue = JsObjectToString(env, jsProValue); - DMLOG(DM_LOG_INFO, "Property name=%s, string, value=%s", strProName.c_str(), natValue.c_str()); - jsonObj[strProName] = natValue; + jsonObj[strProName] = JsObjectToString(env, jsProValue); break; } case napi_boolean: { bool elementValue = false; napi_get_value_bool(env, jsProValue, &elementValue); - DMLOG(DM_LOG_INFO, "Property name=%s, boolean, value=%d.", strProName.c_str(), elementValue); jsonObj[strProName] = elementValue; break; } @@ -663,14 +657,11 @@ void DeviceManagerNapi::JsToJsonObject(const napi_env &env, const napi_value &ob DMLOG(DM_LOG_ERROR, "Property name=%s, Property int32_t parse error", strProName.c_str()); } else { jsonObj[strProName] = elementValue; - DMLOG(DM_LOG_INFO, "Property name=%s, number, value=%d.", strProName.c_str(), elementValue); } break; } - default: { - DMLOG(DM_LOG_ERROR, "Property name=%s, value type not support.", strProName.c_str()); + default: break; - } } } } @@ -678,8 +669,8 @@ void DeviceManagerNapi::JsToJsonObject(const napi_env &env, const napi_value &ob void DeviceManagerNapi::JsToDmAuthInfo(const napi_env &env, const napi_value &object, std::string &extra) { DMLOG(DM_LOG_INFO, "%s called.", __func__); - int authType = -1; - int token = -1; + int32_t authType = -1; + int32_t token = -1; JsObjectToInt(env, object, "authType", authType); JsObjectToInt(env, object, "token", token); @@ -944,6 +935,8 @@ napi_value DeviceManagerNapi::StopDeviceDiscoverSync(napi_env env, napi_callback napi_value DeviceManagerNapi::AuthenticateDevice(napi_env env, napi_callback_info info) { + const int32_t PARAM_INDEX_ONE = 1; + const int32_t PARAM_INDEX_TWO = 2; DMLOG(DM_LOG_INFO, "AuthenticateDevice in"); GET_PARAMS(env, info, DM_NAPI_ARGS_THREE); napi_value result = nullptr; @@ -952,15 +945,15 @@ napi_value DeviceManagerNapi::AuthenticateDevice(napi_env env, napi_callback_inf NAPI_ASSERT(env, deviceInfoType == napi_object, "Wrong argument type. Object expected."); napi_valuetype authparamType; - napi_typeof(env, argv[1], &authparamType); + napi_typeof(env, argv[PARAM_INDEX_ONE], &authparamType); NAPI_ASSERT(env, authparamType == napi_object, "Wrong argument type. Object expected."); napi_valuetype eventHandleType = napi_undefined; - napi_typeof(env, argv[2], &eventHandleType); + napi_typeof(env, argv[PARAM_INDEX_TWO], &eventHandleType); NAPI_ASSERT(env, eventHandleType == napi_function, "Wrong argument type. Function expected."); authAsyncCallbackInfo_.env = env; - napi_create_reference(env, argv[2], 1, &authAsyncCallbackInfo_.callback); + napi_create_reference(env, argv[PARAM_INDEX_TWO], 1, &authAsyncCallbackInfo_.callback); DeviceManagerNapi *deviceManagerWrapper = nullptr; napi_unwrap(env, thisVar, reinterpret_cast(&deviceManagerWrapper)); @@ -978,7 +971,7 @@ napi_value DeviceManagerNapi::AuthenticateDevice(napi_env env, napi_callback_inf DmAppImageInfo appImageInfo(nullptr, 0, nullptr, 0); std::string extra; - JsToDmAppImageInfoAndDmExtra(env, argv[1], appImageInfo, extra, authAsyncCallbackInfo_.authType); + JsToDmAppImageInfoAndDmExtra(env, argv[PARAM_INDEX_ONE], appImageInfo, extra, authAsyncCallbackInfo_.authType); int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(deviceManagerWrapper->bundleName_, deviceInfo, appImageInfo, extra, authCallback); @@ -1167,9 +1160,7 @@ void DeviceManagerNapi::HandleCreateDmCallBack(const napi_env &env, AsyncCallbac DMLOG(DM_LOG_ERROR, "Create DeviceManagerNapi for bunderName %s failed", asCallbackInfo->bundleName); asCallbackInfo->status = -1; } - if (asCallbackInfo->status == 0) { - DMLOG(DM_LOG_INFO, "InitDeviceManager for bunderName %s success", asCallbackInfo->bundleName); napi_get_undefined(env, &result[0]); napi_value callback = nullptr; napi_value callResult = nullptr; @@ -1177,18 +1168,16 @@ void DeviceManagerNapi::HandleCreateDmCallBack(const napi_env &env, AsyncCallbac napi_call_function(env, nullptr, callback, DM_NAPI_ARGS_TWO, &result[0], &callResult); napi_delete_reference(env, asCallbackInfo->callback); } else { - DMLOG(DM_LOG_INFO, "InitDeviceManager for bunderName %s failed", asCallbackInfo->bundleName); napi_value message = nullptr; napi_create_object(env, &result[0]); napi_create_int32(env, asCallbackInfo->status, &message); napi_set_named_property(env, result[0], "code", message); napi_get_undefined(env, &result[1]); } + DMLOG(DM_LOG_INFO, "bunderName %s, status:%d", asCallbackInfo->bundleName, asCallbackInfo->status); napi_delete_async_work(env, asCallbackInfo->asyncWork); delete asCallbackInfo; - }, - (void *)asCallbackInfo, - &asCallbackInfo->asyncWork); + }, (void *)asCallbackInfo, &asCallbackInfo->asyncWork); napi_queue_async_work(env, asCallbackInfo->asyncWork); } diff --git a/services/devicemanagerservice/include/auth/hichain_connector.h b/services/devicemanagerservice/include/auth/hichain_connector.h index 18829cb61..61534df59 100644 --- a/services/devicemanagerservice/include/auth/hichain_connector.h +++ b/services/devicemanagerservice/include/auth/hichain_connector.h @@ -57,15 +57,15 @@ class HichainAuthenCallBack { public: static bool onTransmit(int64_t requestId, const uint8_t *data, uint32_t dataLen); static void onSessionKeyReturned(int64_t requestId, const uint8_t *sessionKey, uint32_t sessionKeyLen); - static void onFinish(int64_t requestId, int operationCode, const char *returnData); - static void onError(int64_t requestId, int operationCode, int errorCode, const char *errorReturn); - static char *onRequest(int64_t requestId, int operationCode, const char *reqParams); + static void onFinish(int64_t requestId, int32_t operationCode, const char *returnData); + static void onError(int64_t requestId, int32_t operationCode, int32_t errorCode, const char *errorReturn); + static char *onRequest(int64_t requestId, int32_t operationCode, const char *reqParams); }; class HichainConnector { DECLARE_SINGLE_INSTANCE(HichainConnector); public: - int Init(); + int32_t Init(); bool OnTransmit(int64_t requestId, const uint8_t *data, uint32_t dataLen); int64_t GenRequestId(); void RegisterConnectorCallback(std::shared_ptr callback); diff --git a/services/devicemanagerservice/include/ipc/lite/ipc_server_listenermgr.h b/services/devicemanagerservice/include/ipc/lite/ipc_server_listenermgr.h index 3e39f8cce..26d2ee114 100644 --- a/services/devicemanagerservice/include/ipc/lite/ipc_server_listenermgr.h +++ b/services/devicemanagerservice/include/ipc/lite/ipc_server_listenermgr.h @@ -27,11 +27,11 @@ namespace OHOS { namespace DistributedHardware { typedef struct CommonSvcId { - unsigned int handle; - unsigned int token; - unsigned int cookie; + uint32_t handle; + uint32_t token; + uint32_t cookie; IpcContext *ipcCtx; - unsigned int cbId; + uint32_t cbId; }CommonSvcId; class IpcServerListenermgr { diff --git a/services/devicemanagerservice/include/message/msg_request_auth.h b/services/devicemanagerservice/include/message/msg_request_auth.h index c02fd17b5..f38be9b9e 100644 --- a/services/devicemanagerservice/include/message/msg_request_auth.h +++ b/services/devicemanagerservice/include/message/msg_request_auth.h @@ -44,19 +44,6 @@ public: int32_t GetMsgSlice(); int32_t GetMsgCnt(); std::string GetRequestDeviceId(); - -private: - std::string ToHexString(int32_t value); - std::string EncodeDevInfo(); - static int32_t DecodeFirstPackageMsg(nlohmann::json &json, std::shared_ptr msg); - static void DecodeDeviceInfo(nlohmann::json &json, std::shared_ptr msg); - static std::string StringSub(std::string &thumbStr, int32_t start, int32_t length); - int32_t GetEncodedAppInfo(const uint8_t *dataSrc, size_t srcLen, std::string &outString); - static bool IsMsgValid(std::shared_ptr msgIn, nlohmann::json &json, std::string &deviceId, - int32_t index); - static bool IsAppInfoValid(nlohmann::json &json); - static void SetAuthType(nlohmann::json &json, std::shared_ptr msg); - public: std::shared_ptr mHead_; std::string mHostPkg_; @@ -75,6 +62,17 @@ public: int32_t mMsgCnt_ = 0; int32_t mThumbnailSize_; int32_t mAppIconSize_; +private: + std::string ToHexString(int32_t value); + std::string EncodeDevInfo(); + static int32_t DecodeFirstPackageMsg(nlohmann::json &json, std::shared_ptr msg); + static void DecodeDeviceInfo(nlohmann::json &json, std::shared_ptr msg); + static std::string StringSub(std::string &thumbStr, int32_t start, int32_t length); + int32_t GetEncodedAppInfo(const uint8_t *dataSrc, size_t srcLen, std::string &outString); + static bool IsMsgValid(std::shared_ptr msgIn, nlohmann::json &json, std::string &deviceId, + int32_t index); + static bool IsAppInfoValid(nlohmann::json &json); + static void SetAuthType(nlohmann::json &json, std::shared_ptr msg); }; } } diff --git a/services/devicemanagerservice/src/auth/hichain_connector.cpp b/services/devicemanagerservice/src/auth/hichain_connector.cpp index fe9da1279..fcf56e54d 100644 --- a/services/devicemanagerservice/src/auth/hichain_connector.cpp +++ b/services/devicemanagerservice/src/auth/hichain_connector.cpp @@ -219,7 +219,7 @@ void HichainConnector::GetRelatedGroups(std::string deviceId, std::vectorgetRelatedGroups(DEVICE_MANAGER_APP.c_str(), deviceId.c_str(), + int32_t ret = deviceGroupManager_->getRelatedGroups(DEVICE_MANAGER_APP.c_str(), deviceId.c_str(), &returnGroups, &groupNum); if (ret != 0) { DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups faild , ret: %d.", ret); @@ -303,7 +303,7 @@ int32_t HichainConnector::DelMemberFromGroup(std::string groupId, std::string de jsonObj[FIELD_DELETE_ID] = deviceId; std::string deleteParams = jsonObj.dump(); - int ret = deviceGroupManager_->deleteMemberFromGroup(requestId, DEVICE_MANAGER_APP.c_str(), deleteParams.c_str()); + int32_t ret = deviceGroupManager_->deleteMemberFromGroup(requestId, DEVICE_MANAGER_APP.c_str(), deleteParams.c_str()); if (ret != 0) { DMLOG(DM_LOG_ERROR, "HichainConnector::DelMemberFromGroup faild , ret: %d.", ret); return ret; @@ -318,13 +318,13 @@ void HichainConnector::DeleteGroup(std::string &groupId) jsonObj[FIELD_GROUP_ID] = groupId; std::string disbandParams = jsonObj.dump(); - int ret = deviceGroupManager_->deleteGroup(requestId, DEVICE_MANAGER_APP.c_str(), disbandParams.c_str()); + int32_t ret = deviceGroupManager_->deleteGroup(requestId, DEVICE_MANAGER_APP.c_str(), disbandParams.c_str()); if (ret != 0) { DMLOG(DM_LOG_ERROR, "HichainConnector::DeleteGroup faild , ret: %d.", ret); } } -void HichainAuthenCallBack::onFinish(int64_t requestId, int operationCode, const char *returnData) +void HichainAuthenCallBack::onFinish(int64_t requestId, int32_t operationCode, const char *returnData) { std::string data = ""; if (returnData != nullptr) { @@ -352,7 +352,7 @@ void HichainAuthenCallBack::onFinish(int64_t requestId, int operationCode, const } } -void HichainAuthenCallBack::onError(int64_t requestId, int operationCode, int errorCode, const char *errorReturn) +void HichainAuthenCallBack::onError(int64_t requestId, int32_t operationCode, int32_t errorCode, const char *errorReturn) { (void)errorReturn; DMLOG(DM_LOG_INFO, "HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", @@ -377,7 +377,7 @@ void HichainAuthenCallBack::onError(int64_t requestId, int operationCode, int er } } -char *HichainAuthenCallBack::onRequest(int64_t requestId, int operationCode, const char *reqParams) +char *HichainAuthenCallBack::onRequest(int64_t requestId, int32_t operationCode, const char *reqParams) { if (operationCode != GroupOperationCode::MEMBER_JOIN) { DMLOG(DM_LOG_ERROR, "HichainAuthenCallBack::onRequest operationCode %d", operationCode); diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp index a14342da7..775245f59 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp @@ -192,7 +192,7 @@ static TaskConfig GetTaskConfig(Service *service) return config; } -static int32_t OnRemoteRequest(IServerProxy *iProxy, int funcId, void *origin, +static int32_t OnRemoteRequest(IServerProxy *iProxy, int32_t funcId, void *origin, IpcIo *req, IpcIo *reply) { DMLOG(DM_LOG_INFO, "Receive funcId:%d", funcId); diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index 0c5294e02..f19028cf6 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -328,7 +328,7 @@ ON_IPC_CMD(SERVER_USER_AUTHORIZATION_OPERATION, MessageParcel &data, MessageParc { std::string packageName = data.ReadString(); int32_t action = data.ReadInt32(); - int result = IpcServerAdapter::GetInstance().SetUserOperation(packageName, action); + int32_t result = IpcServerAdapter::GetInstance().SetUserOperation(packageName, action); if (!reply.WriteInt32(action)) { DMLOG(DM_LOG_ERROR, "write result failed"); diff --git a/services/devicemanagerservice/src/softbus/softbus_adapter.cpp b/services/devicemanagerservice/src/softbus/softbus_adapter.cpp index 3103b6a47..d855b7eb1 100644 --- a/services/devicemanagerservice/src/softbus/softbus_adapter.cpp +++ b/services/devicemanagerservice/src/softbus/softbus_adapter.cpp @@ -409,7 +409,7 @@ int32_t SoftbusAdapter::GetConnectionIpAddr(std::string deviceId, std::string &i return DEVICEMANAGER_FAILED; } - for (unsigned int i = 0; i < deviceInfo->addrNum; ++i) { + for (uint32_t i = 0; i < deviceInfo->addrNum; ++i) { // currently, only support CONNECT_ADDR_WLAN if (deviceInfo->addr[i].type != ConnectionAddrType::CONNECTION_ADDR_WLAN && deviceInfo->addr[i].type != ConnectionAddrType::CONNECTION_ADDR_ETH) { @@ -429,7 +429,7 @@ ConnectionAddr *SoftbusAdapter::GetConnectAddrByType(DeviceInfo *deviceInfo, Con if (deviceInfo == nullptr) { return nullptr; } - for (unsigned int i = 0; i < deviceInfo->addrNum; ++i) { + for (uint32_t i = 0; i < deviceInfo->addrNum; ++i) { if (deviceInfo->addr[i].type == type) { return &deviceInfo->addr[i]; } diff --git a/utils/src/anonymous_string.cpp b/utils/src/anonymous_string.cpp index c3fdd4f3e..f5834ee37 100644 --- a/utils/src/anonymous_string.cpp +++ b/utils/src/anonymous_string.cpp @@ -21,9 +21,9 @@ namespace OHOS { namespace DistributedHardware { std::string GetAnonyString(const std::string &value) { - const int INT32_SHORT_ID_LENGTH = 20; - const int INT32_PLAINTEXT_LENGTH = 4; - const int INT32_MIN_ID_LENGTH = 3; + const int32_t INT32_SHORT_ID_LENGTH = 20; + const int32_t INT32_PLAINTEXT_LENGTH = 4; + const int32_t INT32_MIN_ID_LENGTH = 3; std::string res; std::string tmpStr("******"); int32_t strLen = value.length(); @@ -46,7 +46,7 @@ std::string GetAnonyString(const std::string &value) std::string GetAnonyInt32(const int32_t value) { - const int INT32_STRING_LENGTH = 40; + const int32_t INT32_STRING_LENGTH = 40; char tempBuffer[INT32_STRING_LENGTH] = ""; int32_t secRet = sprintf_s(tempBuffer, INT32_STRING_LENGTH, "%d", value); if (secRet <= 0) { diff --git a/utils/src/cipher/encrypt_utils.cpp b/utils/src/cipher/encrypt_utils.cpp index c97fc6934..67a39b9c4 100644 --- a/utils/src/cipher/encrypt_utils.cpp +++ b/utils/src/cipher/encrypt_utils.cpp @@ -97,9 +97,10 @@ int32_t EncryptUtils::GetRandomData(uint8_t *randStr, uint32_t len) return ret; } -int32_t EncryptUtils::MbedtlsEncrypt(const uint8_t *plainText, int plainTextLen, uint8_t *cipherText, +int32_t EncryptUtils::MbedtlsEncrypt(const uint8_t *plainText, int32_t plainTextLen, uint8_t *cipherText, int32_t cipherTextLen, int32_t *outLen) { + // Security algorithms do not support open source. Customize if required if (memcpy_s(cipherText, cipherTextLen, plainText, plainTextLen) != DEVICEMANAGER_OK) { return DEVICEMANAGER_COPY_FAILED; } @@ -110,6 +111,7 @@ int32_t EncryptUtils::MbedtlsEncrypt(const uint8_t *plainText, int plainTextLen, int32_t EncryptUtils::MbedtlsDecrypt(const uint8_t *cipherText, int32_t cipherTextLen, uint8_t *plainText, int32_t plainTextLen, int32_t *outLen) { + // Security algorithms do not support open source. Customize if required (void)outLen; if (memcpy_s(plainText, plainTextLen, cipherText, cipherTextLen) != DEVICEMANAGER_OK) { return DEVICEMANAGER_COPY_FAILED; -- Gitee From 7e21c4bcdef0f39e2c08059b90e8feae458539b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E4=B8=8D=E5=87=BA=E5=88=AB=E5=90=8D?= Date: Sun, 12 Sep 2021 15:21:40 +0800 Subject: [PATCH 2/2] codestyle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 想不出别名 --- interfaces/kits/js/src/native_devicemanager_js.cpp | 2 +- .../devicemanagerservice/src/auth/hichain_connector.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index 9d00ded1e..1120fa805 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -718,7 +718,7 @@ void DeviceManagerNapi::CreateDmCallback(std::string &bundleName, std::string &e discoverCallback->IncreaseRefCount(); return; } - + if (eventType == DM_NAPI_EVENT_DMFA_CALLBACK) { auto iter = g_dmfaCallbackMap.find(bundleName); if (iter == g_dmfaCallbackMap.end()) { diff --git a/services/devicemanagerservice/src/auth/hichain_connector.cpp b/services/devicemanagerservice/src/auth/hichain_connector.cpp index fcf56e54d..afb7695ac 100644 --- a/services/devicemanagerservice/src/auth/hichain_connector.cpp +++ b/services/devicemanagerservice/src/auth/hichain_connector.cpp @@ -303,7 +303,8 @@ int32_t HichainConnector::DelMemberFromGroup(std::string groupId, std::string de jsonObj[FIELD_DELETE_ID] = deviceId; std::string deleteParams = jsonObj.dump(); - int32_t ret = deviceGroupManager_->deleteMemberFromGroup(requestId, DEVICE_MANAGER_APP.c_str(), deleteParams.c_str()); + int32_t ret = deviceGroupManager_->deleteMemberFromGroup(requestId, DEVICE_MANAGER_APP.c_str(), + deleteParams.c_str()); if (ret != 0) { DMLOG(DM_LOG_ERROR, "HichainConnector::DelMemberFromGroup faild , ret: %d.", ret); return ret; @@ -352,7 +353,8 @@ void HichainAuthenCallBack::onFinish(int64_t requestId, int32_t operationCode, c } } -void HichainAuthenCallBack::onError(int64_t requestId, int32_t operationCode, int32_t errorCode, const char *errorReturn) +void HichainAuthenCallBack::onError(int64_t requestId, int32_t operationCode, int32_t errorCode, + const char *errorReturn) { (void)errorReturn; DMLOG(DM_LOG_INFO, "HichainAuthenCallBack::onError reqId:%lld, operation:%d, errorCode:%d.", -- Gitee