mirror of
https://gitee.com/openharmony/distributeddatamgr_pasteboard
synced 2024-11-23 07:59:55 +00:00
!913 fix:shareOption增加local device判断
Merge pull request !913 from quyihao/master
This commit is contained in:
commit
6ce5424633
@ -2048,20 +2048,17 @@ bool PasteboardService::SetDistributedData(int32_t user, PasteData &data)
|
||||
if (!IsAllowSendData()) {
|
||||
return false;
|
||||
}
|
||||
if (data.GetShareOption() == InApp) {
|
||||
PASTEBOARD_HILOGE(
|
||||
PASTEBOARD_MODULE_SERVICE, "data share option is in app, dataId:%{public}d", data.GetDataId());
|
||||
return false;
|
||||
}
|
||||
ShareOption shareOpt = data.GetShareOption();
|
||||
PASTEBOARD_CHECK_AND_RETURN_RET_LOGE(shareOpt != InApp, false, PASTEBOARD_MODULE_SERVICE,
|
||||
"data share option is in app, dataId:%{public}u", data.GetDataId());
|
||||
PASTEBOARD_CHECK_AND_RETURN_RET_LOGE(shareOpt != LocalDevice, false, PASTEBOARD_MODULE_SERVICE,
|
||||
"data share option is local device, dataId:%{public}u", data.GetDataId());
|
||||
auto networkId = DMAdapter::GetInstance().GetLocalNetworkId();
|
||||
if (networkId.empty()) {
|
||||
PASTEBOARD_HILOGE(PASTEBOARD_MODULE_SERVICE, "networkId is empty.");
|
||||
return false;
|
||||
}
|
||||
PASTEBOARD_CHECK_AND_RETURN_RET_LOGE(!networkId.empty(), false, PASTEBOARD_MODULE_SERVICE, "networkId is empty.");
|
||||
auto clipPlugin = GetClipPlugin();
|
||||
if (clipPlugin == nullptr) {
|
||||
RADAR_REPORT(DFX_SET_PASTEBOARD, DFX_CHECK_ONLINE_DEVICE, DFX_SUCCESS);
|
||||
PASTEBOARD_HILOGE(PASTEBOARD_MODULE_SERVICE, "clip plugin is null, dataId:%{public}d", data.GetDataId());
|
||||
PASTEBOARD_HILOGE(PASTEBOARD_MODULE_SERVICE, "clip plugin is null, dataId:%{public}u", data.GetDataId());
|
||||
return false;
|
||||
}
|
||||
RADAR_REPORT(DFX_SET_PASTEBOARD, DFX_LOAD_DISTRIBUTED_PLUGIN, DFX_SUCCESS);
|
||||
@ -2076,7 +2073,7 @@ bool PasteboardService::SetDistributedData(int32_t user, PasteData &data)
|
||||
event.status = ClipPlugin::EVT_NORMAL;
|
||||
event.dataType = data.GetMimeTypes();
|
||||
currentEvent_ = event;
|
||||
PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "dataId:%{public}d, seqId:%{public}d, expiration:%{public}" PRIu64,
|
||||
PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "dataId:%{public}u, seqId:%{public}hu, expiration:%{public}" PRIu64,
|
||||
data.GetDataId(), event.seqId, event.expiration);
|
||||
std::thread thread([this, clipPlugin, event, user, data]() mutable {
|
||||
if (data.IsDelayRecord()) {
|
||||
@ -2086,7 +2083,7 @@ bool PasteboardService::SetDistributedData(int32_t user, PasteData &data)
|
||||
std::vector<uint8_t> rawData;
|
||||
if (!data.Encode(rawData)) {
|
||||
PASTEBOARD_HILOGE(PASTEBOARD_MODULE_SERVICE,
|
||||
"distributed data encode failed, dataId:%{public}d, seqId:%{public}d", data.GetDataId(), event.seqId);
|
||||
"distributed data encode failed, dataId:%{public}u, seqId:%{public}hu", data.GetDataId(), event.seqId);
|
||||
} else {
|
||||
clipPlugin->SetPasteData(event, rawData);
|
||||
}
|
||||
|
@ -95,6 +95,38 @@ static constexpr OHOS::HiviewDFX::HiLogLabel PASTEBOARD[PASTEBOARD_MODULE_BUTT]
|
||||
"%{public}s# " fmt, __FUNCTION__, ##__VA_ARGS__)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// check then return ret and print log
|
||||
#define CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, log, label, fmt, ...) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
log(label, fmt, ##__VA_ARGS__); \
|
||||
return ret; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// check then return and print log
|
||||
#define CHECK_AND_RETURN_LOG_INNER(cond, log, label, fmt, ...) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
log(label, fmt, ##__VA_ARGS__); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PASTEBOARD_CHECK_AND_RETURN_RET_LOGD(cond, ret, label, fmt, ...) \
|
||||
CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, PASTEBOARD_HILOGD, label, fmt, ##__VA_ARGS__)
|
||||
#define PASTEBOARD_CHECK_AND_RETURN_RET_LOGW(cond, ret, label, fmt, ...) \
|
||||
CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, PASTEBOARD_HILOGW, label, fmt, ##__VA_ARGS__)
|
||||
#define PASTEBOARD_CHECK_AND_RETURN_RET_LOGE(cond, ret, label, fmt, ...) \
|
||||
CHECK_AND_RETURN_RET_LOG_INNER(cond, ret, PASTEBOARD_HILOGE, label, fmt, ##__VA_ARGS__)
|
||||
#define PASTEBOARD_CHECK_AND_RETURN_LOGD(cond, label, fmt, ...) \
|
||||
CHECK_AND_RETURN_LOG_INNER(cond, PASTEBOARD_HILOGD, label, fmt, ##__VA_ARGS__)
|
||||
#define PASTEBOARD_CHECK_AND_RETURN_LOGW(cond, label, fmt, ...) \
|
||||
CHECK_AND_RETURN_LOG_INNER(cond, PASTEBOARD_HILOGW, label, fmt, ##__VA_ARGS__)
|
||||
#define PASTEBOARD_CHECK_AND_RETURN_LOGE(cond, label, fmt, ...) \
|
||||
CHECK_AND_RETURN_LOG_INNER(cond, PASTEBOARD_HILOGE, label, fmt, ##__VA_ARGS__)
|
||||
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user