mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-20 21:58:27 -04:00
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_NATIVE_EVENT_H
|
||||
#define OHOS_DEVICE_MANAGER_NATIVE_EVENT_H
|
||||
|
||||
|
||||
@@ -549,7 +549,7 @@ void DeviceManagerModule::JsToDmBuffer(const JSIValue &object,
|
||||
}
|
||||
*bufferPtr = (uint8_t*)calloc(sizeof(uint8_t), length);
|
||||
if (*bufferPtr == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "low memory, calloc return nullptr, length is %d, filed %s", length, fieldStr.c_str());
|
||||
DMLOG(DM_LOG_ERROR, "low memory, calloc return nullptr, length is %zu, filed %s", length, fieldStr.c_str());
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(*bufferPtr, length, data, length) != 0) {
|
||||
|
||||
@@ -72,7 +72,7 @@ AbilityStatus DmAbilityManager::StartAbility(AbilityRole role)
|
||||
if (result == OHOS::ERR_OK) {
|
||||
DMLOG(DM_LOG_INFO, "Start Ability succeed");
|
||||
} else {
|
||||
DMLOG(DM_LOG_INFO, "Start Ability faild");
|
||||
DMLOG(DM_LOG_INFO, "Start Ability failed");
|
||||
mStatus_ = AbilityStatus::ABILITY_STATUS_FAILED;
|
||||
return mStatus_;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ int32_t HichainConnector::CreateGroup(int64_t requestId, const std::string &grou
|
||||
|
||||
ret = deviceGroupManager_->createGroup(userId, requestId, DEVICE_MANAGER_APP.c_str(), jsonObj.dump().c_str());
|
||||
if (ret != 0) {
|
||||
DMLOG(DM_LOG_ERROR, "Faild to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId);
|
||||
DMLOG(DM_LOG_ERROR, "Failed to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -176,12 +176,12 @@ int32_t HichainConnector::GetGroupInfo(std::string queryParams, std::vector<Grou
|
||||
|
||||
ret = deviceGroupManager_->getGroupInfo(userId, DEVICE_MANAGER_APP.c_str(), queryParams.c_str(), &groupVec, &num);
|
||||
if (ret != 0) {
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo faild , ret: %d.", ret);
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo failed , ret: %d.", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (groupVec == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo faild , returnGroups is nullptr");
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo failed , returnGroups is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -333,12 +333,12 @@ void HichainConnector::GetRelatedGroups(std::string deviceId, std::vector<GroupI
|
||||
int32_t ret = deviceGroupManager_->getRelatedGroups(userId, DEVICE_MANAGER_APP.c_str(), deviceId.c_str(),
|
||||
&returnGroups, &groupNum);
|
||||
if (ret != 0) {
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups faild , ret: %d.", ret);
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups failed , ret: %d.", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (returnGroups == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups faild , returnGroups is nullptr");
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups failed , returnGroups is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ int32_t HichainConnector::DelMemberFromGroup(std::string groupId, std::string de
|
||||
int32_t ret = deviceGroupManager_->deleteMemberFromGroup(userId, requestId, DEVICE_MANAGER_APP.c_str(),
|
||||
deleteParams.c_str());
|
||||
if (ret != 0) {
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::DelMemberFromGroup faild , ret: %d.", ret);
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::DelMemberFromGroup failed , ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
@@ -443,7 +443,7 @@ void HichainConnector::DeleteGroup(std::string &groupId)
|
||||
|
||||
ret = deviceGroupManager_->deleteGroup(userId, requestId, DEVICE_MANAGER_APP.c_str(), disbandParams.c_str());
|
||||
if (ret != 0) {
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::DeleteGroup faild , ret: %d.", ret);
|
||||
DMLOG(DM_LOG_ERROR, "HichainConnector::DeleteGroup failed , ret: %d.", ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ static const char *GetName(Service *service)
|
||||
|
||||
static BOOL Initialize(Service *service, Identity identity)
|
||||
{
|
||||
if (service == NULL) {
|
||||
if (service == nullptr) {
|
||||
DMLOG(DM_LOG_WARN, "invalid param");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ static BOOL Initialize(Service *service, Identity identity)
|
||||
|
||||
static BOOL MessageHandle(Service *service, Request *request)
|
||||
{
|
||||
if ((service == NULL) || (request == NULL)) {
|
||||
if ((service == nullptr) || (request == nullptr)) {
|
||||
DMLOG(DM_LOG_WARN, "invalid param");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -85,9 +85,6 @@ static TaskConfig GetTaskConfig(Service *service)
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void DevMgrSvcInit(void)
|
||||
{
|
||||
sleep(WAIT_FOR_SERVER);
|
||||
@@ -96,9 +93,6 @@ static void DevMgrSvcInit(void)
|
||||
.Initialize = Initialize,
|
||||
.MessageHandle = MessageHandle,
|
||||
.GetTaskConfig = GetTaskConfig,
|
||||
// SERVER_IPROXY_IMPL_BEGIN,
|
||||
// .Invoke = OnRemoteRequest,
|
||||
// IPROXY_END,
|
||||
};
|
||||
|
||||
if (!SAMGR_GetInstance()->RegisterService((Service *)&service)) {
|
||||
|
||||
@@ -229,7 +229,7 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, IpcIo &reply)
|
||||
DmDeviceState deviceState = static_cast<DmDeviceState>(IpcIoPopInt32(&reply));
|
||||
uint32_t size;
|
||||
const DmDeviceInfo *deviceInfo = (const DmDeviceInfo *)IpcIoPopFlatObj(&reply, &size);
|
||||
if (pkgName == "" || len == 0 || deviceInfo == NULL) {
|
||||
if (pkgName == "" || len == 0 || deviceInfo == nullptr) {
|
||||
LOGE("OnDeviceOnline, get para failed");
|
||||
return;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, IpcIo &reply)
|
||||
uint16_t subscribeId = IpcIoPopUint16(&reply);
|
||||
uint32_t size;
|
||||
const DmDeviceInfo *deviceInfo = (const DmDeviceInfo *)IpcIoPopFlatObj(&reply, &size);
|
||||
if (pkgName == "" || len == 0 || deviceInfo == NULL) {
|
||||
if (pkgName == "" || len == 0 || deviceInfo == nullptr) {
|
||||
LOGE("OnDeviceChanged, get para failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
LOGI("code = %d, flags= %d.", code, option.GetFlags());
|
||||
LOGI("code = %u, flags= %d.", code, option.GetFlags());
|
||||
auto remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (GetDescriptor() != remoteDescriptor) {
|
||||
LOGI("ReadInterfaceToken fail!");
|
||||
@@ -36,7 +36,7 @@ int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa
|
||||
LOGE("on ipc cmd success");
|
||||
return DM_OK;
|
||||
}
|
||||
LOGW("unsupport code: %d", code);
|
||||
LOGW("unsupport code: %u", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ void DeviceManagerNotify::OnDiscoverySuccess(const std::string &pkgName, uint16_
|
||||
void DeviceManagerNotify::OnAuthResult(const std::string &pkgName, const std::string &deviceId,
|
||||
const std::string &token, uint32_t status, uint32_t reason)
|
||||
{
|
||||
LOGI("DeviceManagerNotify::OnAuthResult pkgName:%s, status:%d, reason:%d", pkgName.c_str(), status, reason);
|
||||
LOGI("DeviceManagerNotify::OnAuthResult pkgName:%s, status:%d, reason:%u", pkgName.c_str(), status, reason);
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (authenticateCallback_.count(pkgName) == 0) {
|
||||
LOGE("DeviceManager OnAuthResult: no register authCallback for this package");
|
||||
|
||||
@@ -161,7 +161,7 @@ int32_t HiChainConnector::GetGroupInfo(std::string queryParams, std::vector<Grou
|
||||
LOGE("HiChainConnector::GetGroupInfo group failed, groupNum is 0.");
|
||||
return false;
|
||||
}
|
||||
LOGI("HiChainConnector::GetGroupInfo group(%s), groupNum(%d)", groupVec, num);
|
||||
LOGI("HiChainConnector::GetGroupInfo group(%s), groupNum(%u)", groupVec, num);
|
||||
std::string relatedGroups = std::string(groupVec);
|
||||
deviceGroupManager_->destroyInfo(&groupVec);
|
||||
nlohmann::json jsonObject = nlohmann::json::parse(relatedGroups);
|
||||
@@ -188,7 +188,7 @@ int32_t HiChainConnector::GetGroupInfo(const int32_t userId, std::string queryPa
|
||||
return false;
|
||||
}
|
||||
if (groupVec == nullptr) {
|
||||
LOGE("HiChainConnector::GetGroupInfo failed , returnGroups is nullptr");
|
||||
LOGE("HiChainConnector::GetGroupInfo failed , returnGroups is nullptr.");
|
||||
return false;
|
||||
}
|
||||
if (num == 0) {
|
||||
|
||||
@@ -126,9 +126,8 @@ int32_t DmTimer::CreateTimeFd()
|
||||
return DM_STATUS_FINISH;
|
||||
}
|
||||
LOGI("DmTimer %s creatTimeFd", mTimerName_.c_str());
|
||||
int ret = 0;
|
||||
|
||||
ret = pipe(mTimeFd_);
|
||||
int ret = pipe(mTimeFd_);
|
||||
if (ret < 0) {
|
||||
LOGE("DmTimer %s CreateTimeFd fail:(%d) errno(%d)", mTimerName_.c_str(), ret, errno);
|
||||
return ret;
|
||||
|
||||
@@ -46,7 +46,7 @@ void DeviceManagerServiceListener::OnDeviceStateChange(const std::string &pkgNam
|
||||
void DeviceManagerServiceListener::OnDeviceFound(const std::string &pkgName, uint16_t subscribeId,
|
||||
const DmDeviceInfo &info)
|
||||
{
|
||||
LOGI("call OnDeviceFound for %s, originId %d, deviceId %s", pkgName.c_str(), subscribeId,
|
||||
LOGI("call OnDeviceFound for %s, originId %hu, deviceId %s", pkgName.c_str(), subscribeId,
|
||||
GetAnonyString(std::string(info.deviceId)).c_str());
|
||||
std::shared_ptr<IpcNotifyDeviceFoundReq> pReq = std::make_shared<IpcNotifyDeviceFoundReq>();
|
||||
std::shared_ptr<IpcRsp> pRsp = std::make_shared<IpcRsp>();
|
||||
|
||||
@@ -27,7 +27,7 @@ const int32_t SESSION_CANCEL_TIMEOUT = 0;
|
||||
|
||||
static void TimeOut(void *data, DmTimer& timer)
|
||||
{
|
||||
LOGE("time out ");
|
||||
LOGE("time out");
|
||||
DmDiscoveryManager *discoveryMgr = (DmDiscoveryManager *)data;
|
||||
if (discoveryMgr == nullptr) {
|
||||
LOGE("time out error");
|
||||
|
||||
@@ -20,7 +20,7 @@ int32_t main(int32_t argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
while (1) {
|
||||
while (true) {
|
||||
pause();
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -51,7 +51,7 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi
|
||||
(void)context;
|
||||
(void)ipcMsg;
|
||||
(void)data;
|
||||
if (arg == NULL) {
|
||||
if (arg == nullptr) {
|
||||
LOGE("package name is NULL.");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
@@ -60,12 +60,12 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi
|
||||
if (IpcServerListenermgr::GetInstance().GetListenerByPkgName(pkgName, &svcId) != DM_OK) {
|
||||
LOGE("not found client by package name.");
|
||||
free(arg);
|
||||
arg = NULL;
|
||||
arg = nullptr;
|
||||
return DM_FAILED;
|
||||
}
|
||||
IpcServerListenermgr::GetInstance().UnregisterListener(pkgName);
|
||||
free(arg);
|
||||
arg = NULL;
|
||||
arg = nullptr;
|
||||
#ifdef __LINUX__
|
||||
BinderRelease(svcId.ipcCtx, svcId.handle);
|
||||
#endif
|
||||
@@ -83,7 +83,7 @@ int32_t RegisterDeviceManagerListener(IpcIo *req, IpcIo *reply)
|
||||
size_t len = 0;
|
||||
uint8_t *name = IpcIoPopString(req, &len);
|
||||
SvcIdentity *svc = IpcIoPopSvc(req);
|
||||
if (name == NULL || svc == NULL || len == 0) {
|
||||
if (name == nullptr || svc == nullptr || len == 0) {
|
||||
LOGE("get para failed");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ int32_t RegisterDeviceManagerListener(IpcIo *req, IpcIo *reply)
|
||||
svcId.ipcCtx = svc->ipcContext;
|
||||
BinderAcquire(svcId.ipcCtx, svcId.handle);
|
||||
free(svc);
|
||||
svc = NULL;
|
||||
svc = nullptr;
|
||||
#endif
|
||||
if (len == 0 || len > MALLOC_MAX_LEN) {
|
||||
LOGE("malloc length invalid!");
|
||||
@@ -157,7 +157,7 @@ static const char *GetName(Service *service)
|
||||
|
||||
static BOOL Initialize(Service *service, Identity identity)
|
||||
{
|
||||
if (service == NULL) {
|
||||
if (service == nullptr) {
|
||||
LOGW("invalid param");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ static BOOL Initialize(Service *service, Identity identity)
|
||||
|
||||
static BOOL MessageHandle(Service *service, Request *request)
|
||||
{
|
||||
if ((service == NULL) || (request == NULL)) {
|
||||
if ((service == nullptr) || (request == nullptr)) {
|
||||
LOGW("invalid param");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,10 @@ ON_IPC_SET_REQUEST(SERVER_DISCOVER_FINISH, std::shared_ptr<IpcReq> pBaseReq, Mes
|
||||
|
||||
ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
if (pBaseRsp == nullptr) {
|
||||
LOGE("pBaseRsp is null");
|
||||
return DM_FAILED;
|
||||
}
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ void IpcServerStub::OnStop()
|
||||
|
||||
int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
LOGI("code = %d, flags= %d.", code, option.GetFlags());
|
||||
LOGI("code = %u, flags= %d.", code, option.GetFlags());
|
||||
auto remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (GetDescriptor() != remoteDescriptor) {
|
||||
LOGI("ReadInterfaceToken fail!");
|
||||
|
||||
@@ -70,7 +70,7 @@ int32_t GetRandomData(uint8_t *randStr, uint32_t len)
|
||||
break;
|
||||
}
|
||||
ret = DM_OK;
|
||||
} while (0);
|
||||
} while (false);
|
||||
if (entropy != nullptr) {
|
||||
free(entropy);
|
||||
}
|
||||
@@ -91,9 +91,9 @@ bool MbedtlsGenRandomStr(char *szOut, int32_t szOutLen, bool numberOnly)
|
||||
const int32_t NUMBER_COUNT = 10;
|
||||
const int32_t ALPHA_COUNT = 26;
|
||||
const int32_t ALPHA_BYTE_COUNT = 2;
|
||||
int32_t M = numberOnly ? NUMBER_COUNT : (NUMBER_COUNT + ALPHA_BYTE_COUNT * ALPHA_COUNT);
|
||||
int32_t tmpNum = numberOnly ? NUMBER_COUNT : (NUMBER_COUNT + ALPHA_BYTE_COUNT * ALPHA_COUNT);
|
||||
for (int32_t i = 0; i < szOutLen; i++) {
|
||||
uint32_t idx = ((uint32_t)szOut[i] % M);
|
||||
uint32_t idx = ((uint32_t)szOut[i] % tmpNum);
|
||||
char base;
|
||||
if (idx < NUMBER_COUNT) {
|
||||
base = '0';
|
||||
|
||||
Reference in New Issue
Block a user