codestyle

Signed-off-by: 想不出别名 <zhengjianming1@huawei.com>
This commit is contained in:
想不出别名
2021-09-12 14:31:51 +08:00
parent 05170e48de
commit 744e647dfe
15 changed files with 79 additions and 90 deletions
@@ -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
{
@@ -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;
@@ -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;
@@ -283,7 +283,7 @@ void DeviceManagerNotify::OnCheckAuthResult(std::string &pkgName, std::string &d
void DeviceManagerNotify::OnFaCall(std::string &pkgName, std::string &paramJson)
{
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<std::mutex> autoLock(lock_);
if (dmFaCallback_.count(pkgName) == 0) {
DMLOG(DM_LOG_ERROR, "DeviceManager DmFaCallback not register");
@@ -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<OHOS::DistributedHardware::DmDeviceInfo>& 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 &paramResult);
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,
@@ -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<std::string, DeviceManagerNapi *> g_deviceManagerMap;
std::map<std::string, std::shared_ptr<DmNapiInitCallback>> g_initCallbackMap;
@@ -57,13 +59,9 @@ std::map<std::string, std::shared_ptr<DmNapiCheckAuthCallback>> g_checkAuthCallb
std::map<std::string, std::shared_ptr<DmNapiDeviceManagerFaCallback>> 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<DmDeviceInfo> &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<void **>(&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);
}
@@ -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<GroupCreateCallback> callback);
@@ -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 {
@@ -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<MsgRequestAuth> msg);
static void DecodeDeviceInfo(nlohmann::json &json, std::shared_ptr<MsgRequestAuth> 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<MsgRequestAuth> 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<MsgRequestAuth> msg);
public:
std::shared_ptr<MsgHead> 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<MsgRequestAuth> msg);
static void DecodeDeviceInfo(nlohmann::json &json, std::shared_ptr<MsgRequestAuth> 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<MsgRequestAuth> 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<MsgRequestAuth> msg);
};
}
}
@@ -219,7 +219,7 @@ void HichainConnector::GetRelatedGroups(std::string deviceId, std::vector<GroupI
DMLOG(DM_LOG_INFO, "HichainConnector::GetRelatedGroups Start to get local related groups.");
uint32_t groupNum = 0;
char *returnGroups = nullptr;
int ret = deviceGroupManager_->getRelatedGroups(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);
@@ -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);
@@ -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");
@@ -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];
}
+4 -4
View File
@@ -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) {
+3 -1
View File
@@ -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;