mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-21 06:05:22 -04:00
@@ -66,9 +66,9 @@ public:
|
||||
}
|
||||
private:
|
||||
std::string deviceId_;
|
||||
int32_t pinToken_;
|
||||
int32_t status_;
|
||||
int32_t reason_;
|
||||
int32_t pinToken_ {0};
|
||||
int32_t status_ {0};
|
||||
int32_t reason_ {0};
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -56,8 +56,8 @@ public:
|
||||
}
|
||||
private:
|
||||
std::string deviceId_;
|
||||
int32_t result_;
|
||||
int32_t flag_;
|
||||
int32_t result_ {0};
|
||||
int32_t flag_ {0};
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
subscribeId_ = subscribeId;
|
||||
}
|
||||
private:
|
||||
uint16_t subscribeId_;
|
||||
uint16_t subscribeId_ {0};
|
||||
DmDeviceInfo dmDeviceInfo_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
dmDeviceInfo_ = dmDeviceInfo;
|
||||
}
|
||||
private:
|
||||
int32_t deviceState_;
|
||||
int32_t deviceState_ {0};
|
||||
DmDeviceInfo dmDeviceInfo_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -45,8 +45,8 @@ public:
|
||||
result_ = result;
|
||||
}
|
||||
private:
|
||||
uint16_t subscribeId_;
|
||||
int32_t result_;
|
||||
uint16_t subscribeId_ {0};
|
||||
int32_t result_ {0};
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t action_;
|
||||
int32_t action_ {0};
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
subscribeId_ = subscribeId;
|
||||
}
|
||||
private:
|
||||
uint16_t subscribeId_;
|
||||
uint16_t subscribeId_ {0};
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class MsgRequestAuth {
|
||||
public:
|
||||
MsgRequestAuth() {};
|
||||
MsgRequestAuth() = default;
|
||||
~MsgRequestAuth() = default;
|
||||
MsgRequestAuth(std::string &token, std::string hostPkgName, std::string targetPkgName,
|
||||
const DmDeviceInfo &devReqInfo, const DmAppImageInfo &imageInfo, std::string &extras) : MsgRequestAuth(
|
||||
token, hostPkgName, targetPkgName, GROUP_VISIBILITY_IS_PRIVATE, devReqInfo, imageInfo, extras) {};
|
||||
@@ -45,7 +46,7 @@ public:
|
||||
int32_t GetMsgCnt();
|
||||
std::string GetRequestDeviceId();
|
||||
public:
|
||||
std::shared_ptr<MsgHead> mHead_;
|
||||
std::shared_ptr<MsgHead> mHead_ {nullptr};
|
||||
std::string mHostPkg_;
|
||||
std::string mTargetPkg_;
|
||||
std::string mDeviceName_;
|
||||
@@ -56,12 +57,12 @@ public:
|
||||
std::string mAppDescription_;
|
||||
std::string mAppIcon_;
|
||||
std::string mAppThumbnail_;
|
||||
int32_t mAuthType_;
|
||||
int32_t mGroupVisibility_;
|
||||
int32_t mMsgSlice_;
|
||||
int32_t mMsgCnt_ = 0;
|
||||
int32_t mThumbnailSize_;
|
||||
int32_t mAppIconSize_;
|
||||
int32_t mAuthType_ {AUTH_TYPE_PIN};
|
||||
int32_t mGroupVisibility_ {GROUP_VISIBILITY_IS_PRIVATE};
|
||||
int32_t mMsgSlice_ {0};
|
||||
int32_t mMsgCnt_ {0};
|
||||
int32_t mThumbnailSize_ {0};
|
||||
int32_t mAppIconSize_ {0};
|
||||
private:
|
||||
std::string ToHexString(int32_t value);
|
||||
std::string EncodeDevInfo();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "constants.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include "msg_head.h"
|
||||
@@ -43,16 +44,15 @@ public:
|
||||
void SavePinCode(int32_t pinCode);
|
||||
int64_t GetRequestId();
|
||||
std::vector<std::string> GetSyncGroupList();
|
||||
|
||||
private:
|
||||
std::shared_ptr<MsgHead> mHead_;
|
||||
int32_t mReply_;
|
||||
std::shared_ptr<MsgHead> mHead_ {nullptr};
|
||||
int32_t mReply_ {SESSION_REPLY_UNKNOWN};
|
||||
std::string mNetId_;
|
||||
std::string mGroupId_;
|
||||
std::string mGroupName_;
|
||||
std::string mDeviceId_;
|
||||
int32_t mPinCode_;
|
||||
int64_t mRequestId_;
|
||||
int32_t mPinCode_ {-1};
|
||||
int64_t mRequestId_ {-1};
|
||||
std::vector<std::string> mSyncGroupList_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ int32_t IpcServerAdapter::ModuleInit()
|
||||
int32_t IpcServerAdapter::GetTrustedDeviceList(std::string &pkgName, std::string &extra,
|
||||
DmDeviceInfo **info, int32_t *infoNum)
|
||||
{
|
||||
if (info == nullptr || infoNum == nullptr) {
|
||||
return DEVICEMANAGER_NULLPTR;
|
||||
}
|
||||
DMLOG(DM_LOG_INFO, "In, pkgName: %s", pkgName.c_str());
|
||||
NodeBasicInfo *nodeInfo = nullptr;
|
||||
int32_t ret = SoftbusAdapter::GetTrustDevices(pkgName, &nodeInfo, infoNum);
|
||||
@@ -91,11 +94,14 @@ int32_t IpcServerAdapter::GetTrustedDeviceList(std::string &pkgName, std::string
|
||||
for (int32_t i = 0; i < *infoNum; ++i) {
|
||||
NodeBasicInfo *nodeBasicInfo = nodeInfo + i;
|
||||
DmDeviceInfo *deviceInfo = *info + i;
|
||||
|
||||
(void)memcpy_s(deviceInfo->deviceId, sizeof(deviceInfo->deviceId), nodeBasicInfo->networkId,
|
||||
std::min(sizeof(deviceInfo->deviceId), sizeof(nodeBasicInfo->networkId)));
|
||||
(void)memcpy_s(deviceInfo->deviceName, sizeof(deviceInfo->deviceName), nodeBasicInfo->deviceName,
|
||||
std::min(sizeof(deviceInfo->deviceName), sizeof(nodeBasicInfo->deviceName)));
|
||||
if (memcpy_s(deviceInfo->deviceId, sizeof(deviceInfo->deviceId), nodeBasicInfo->networkId,
|
||||
std::min(sizeof(deviceInfo->deviceId), sizeof(nodeBasicInfo->networkId))) != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "memcpy failed");
|
||||
}
|
||||
if (memcpy_s(deviceInfo->deviceName, sizeof(deviceInfo->deviceName), nodeBasicInfo->deviceName,
|
||||
std::min(sizeof(deviceInfo->deviceName), sizeof(nodeBasicInfo->deviceName))) != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "memcpy failed");
|
||||
}
|
||||
deviceInfo->deviceTypeId = (DMDeviceType)nodeBasicInfo->deviceTypeId;
|
||||
}
|
||||
FreeNodeInfo(nodeInfo);
|
||||
|
||||
@@ -229,8 +229,12 @@ ON_IPC_CMD(START_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::string pkgName = data.ReadString();
|
||||
DmSubscribeInfo *subscribeInfo = (DmSubscribeInfo *)data.ReadRawData(sizeof(DmSubscribeInfo));
|
||||
DMLOG(DM_LOG_INFO, "pkgName:%s, subscribeId: %d", pkgName.c_str(), subscribeInfo->subscribeId);
|
||||
int32_t result = IpcServerAdapter::GetInstance().StartDeviceDiscovery(pkgName, *subscribeInfo);
|
||||
int32_t result = DEVICEMANAGER_NULLPTR;
|
||||
|
||||
if (subscribeInfo != nullptr) {
|
||||
DMLOG(DM_LOG_INFO, "pkgName:%s, subscribeId: %d", pkgName.c_str(), subscribeInfo->subscribeId);
|
||||
result = IpcServerAdapter::GetInstance().StartDeviceDiscovery(pkgName, *subscribeInfo);
|
||||
}
|
||||
if (!reply.WriteInt32(result)) {
|
||||
DMLOG(DM_LOG_ERROR, "write result failed");
|
||||
return DEVICEMANAGER_WRITE_FAILED;
|
||||
@@ -260,8 +264,12 @@ ON_IPC_CMD(AUTHENTICATE_DEVICE, MessageParcel &data, MessageParcel &reply)
|
||||
int32_t appThumbnailLen = data.ReadInt32();
|
||||
uint8_t *appIcon = appIconLen > 0? (uint8_t *)data.ReadRawData(appIconLen) : nullptr;
|
||||
uint8_t *appThumbnail = appThumbnailLen > 0? (uint8_t *)data.ReadRawData(appThumbnailLen) : nullptr;
|
||||
DmAppImageInfo imageInfo(appIcon, appIconLen, appThumbnail, appThumbnailLen);
|
||||
int32_t result = IpcServerAdapter::GetInstance().AuthenticateDevice(pkgName, *deviceInfo, imageInfo, extra);
|
||||
int32_t result = DEVICEMANAGER_NULLPTR;
|
||||
|
||||
if (appIcon != nullptr && appThumbnail != nullptr) {
|
||||
DmAppImageInfo imageInfo(appIcon, appIconLen, appThumbnail, appThumbnailLen);
|
||||
result = IpcServerAdapter::GetInstance().AuthenticateDevice(pkgName, *deviceInfo, imageInfo, extra);
|
||||
}
|
||||
if (!reply.WriteInt32(result)) {
|
||||
DMLOG(DM_LOG_ERROR, "write result failed");
|
||||
return DEVICEMANAGER_WRITE_FAILED;
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace DistributedHardware {
|
||||
namespace {
|
||||
const std::string DEVICE_MANAGER_PACKAGE_NAME = "com.huawei.devicemanager";
|
||||
const int32_t CHECK_INTERVAL = 100000; // 100ms
|
||||
const int32_t SUBSCRIBE_ID_PREFIX_LEN = 16;
|
||||
const uint32_t SUBSCRIBE_ID_PREFIX_LEN = 16;
|
||||
const int32_t SUBSCRIBE_ID_MASK = 0x0000FFFF;
|
||||
const int32_t DISCOVER_DEVICEINFO_MAX_SIZE = 20;
|
||||
}
|
||||
@@ -483,20 +483,28 @@ ConnectionAddr *SoftbusAdapter::GetConnectAddr(std::string deviceId)
|
||||
void SoftbusAdapter::NodeBasicInfoCopyToDmDevice(DmDeviceInfo &dmDeviceInfo, NodeBasicInfo &nodeBasicInfo)
|
||||
{
|
||||
(void)memset_s(&dmDeviceInfo, sizeof(DmDeviceInfo), 0, sizeof(DmDeviceInfo));
|
||||
(void)memcpy_s(dmDeviceInfo.deviceId, sizeof(dmDeviceInfo.deviceId), nodeBasicInfo.networkId,
|
||||
std::min(sizeof(dmDeviceInfo.deviceId), sizeof(nodeBasicInfo.networkId)));
|
||||
(void)memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), nodeBasicInfo.deviceName,
|
||||
std::min(sizeof(dmDeviceInfo.deviceName), sizeof(nodeBasicInfo.deviceName)));
|
||||
if (memcpy_s(dmDeviceInfo.deviceId, sizeof(dmDeviceInfo.deviceId), nodeBasicInfo.networkId,
|
||||
std::min(sizeof(dmDeviceInfo.deviceId), sizeof(nodeBasicInfo.networkId))) != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "memcpy failed");
|
||||
}
|
||||
if (memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), nodeBasicInfo.deviceName,
|
||||
std::min(sizeof(dmDeviceInfo.deviceName), sizeof(nodeBasicInfo.deviceName))) != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "memcpy failed");
|
||||
}
|
||||
dmDeviceInfo.deviceTypeId = (DMDeviceType)nodeBasicInfo.deviceTypeId;
|
||||
}
|
||||
|
||||
void SoftbusAdapter::DeviceInfoCopyToDmDevice(DmDeviceInfo &dmDeviceInfo, const DeviceInfo &deviceInfo)
|
||||
{
|
||||
(void)memset_s(&dmDeviceInfo, sizeof(DmDeviceInfo), 0, sizeof(DmDeviceInfo));
|
||||
(void)memcpy_s(dmDeviceInfo.deviceId, sizeof(dmDeviceInfo.deviceId), deviceInfo.devId,
|
||||
std::min(sizeof(dmDeviceInfo.deviceId), sizeof(deviceInfo.devId)));
|
||||
(void)memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), deviceInfo.devName,
|
||||
std::min(sizeof(dmDeviceInfo.deviceName), sizeof(deviceInfo.devName)));
|
||||
if (memcpy_s(dmDeviceInfo.deviceId, sizeof(dmDeviceInfo.deviceId), deviceInfo.devId,
|
||||
std::min(sizeof(dmDeviceInfo.deviceId), sizeof(deviceInfo.devId))) != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "memcpy failed");
|
||||
}
|
||||
if (memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), deviceInfo.devName,
|
||||
std::min(sizeof(dmDeviceInfo.deviceName), sizeof(deviceInfo.devName))) != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "memcpy failed");
|
||||
}
|
||||
dmDeviceInfo.deviceTypeId = (DMDeviceType)deviceInfo.devType;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user