mirror of
https://gitee.com/openharmony/distributeddatamgr_pasteboard
synced 2024-11-27 01:52:01 +00:00
fix:Code format
Signed-off-by: Gavin <caiguangwei2@huawei.com>
This commit is contained in:
parent
0fc4ef7f1b
commit
ec306ce675
15
.gitattributes
vendored
15
.gitattributes
vendored
@ -1,15 +0,0 @@
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.trp filter=lfs diff=lfs merge=lfs -text
|
||||
*.apk filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.asm filter=lfs diff=lfs merge=lfs -text
|
||||
*.8svn filter=lfs diff=lfs merge=lfs -text
|
||||
*.9svn filter=lfs diff=lfs merge=lfs -text
|
||||
*.dylib filter=lfs diff=lfs merge=lfs -text
|
||||
*.exe filter=lfs diff=lfs merge=lfs -text
|
||||
*.a filter=lfs diff=lfs merge=lfs -text
|
||||
*.so filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.dll filter=lfs diff=lfs merge=lfs -text
|
@ -11,7 +11,7 @@
|
||||
"name" : "pasteboard_service",
|
||||
"path" : ["/system/bin/sa_main", "/system/profile/pasteboard_service.json"],
|
||||
"uid" : "pasteboard",
|
||||
"gid" : ["pasteboard", "shell", "dfs_share", "user_data_rw"],
|
||||
"gid" : ["pasteboard", "shell", "dfs_share", "ddms", "user_data_rw"],
|
||||
"caps" : [],
|
||||
"ondemand" : true,
|
||||
"jobs" : {
|
||||
|
@ -131,13 +131,13 @@ public:
|
||||
bool IsDelayRecord() const;
|
||||
void SetDataId(uint32_t dataId);
|
||||
uint32_t GetDataId() const;
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
static PasteData *Unmarshalling(Parcel &parcel);
|
||||
void SetPasteId(const std::string &pasteId);
|
||||
std::string GetPasteId() const;
|
||||
std::string GetDeviceId() const;
|
||||
|
||||
static void ShareOptionToString(ShareOption shareOption, std::string &out);
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
static PasteData *Unmarshalling(Parcel &parcel);
|
||||
static std::string sharePath;
|
||||
static std::string WEBVIEW_PASTEDATA_TAG;
|
||||
static const std::string DISTRIBUTEDFILES_TAG;
|
||||
@ -153,6 +153,7 @@ public:
|
||||
private:
|
||||
void RefreshMimeProp();
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
PasteDataProperty props_;
|
||||
std::vector<std::shared_ptr<PasteDataRecord>> records_;
|
||||
std::string orginAuthority_;
|
||||
|
@ -847,7 +847,6 @@ HWTEST_F(PasteDataTest, PasteDataOperator001, TestSize.Level0)
|
||||
data1.AddRecord(record1);
|
||||
std::string bundleName1 = "com.example.myapplication";
|
||||
data1.SetOrginAuthority(bundleName1);
|
||||
|
||||
PasteData data2;
|
||||
PasteDataRecord::Builder builder2(MIMETYPE_TEXT_URI);
|
||||
std::string uriStr2 = FILE_URI;
|
||||
@ -857,13 +856,12 @@ HWTEST_F(PasteDataTest, PasteDataOperator001, TestSize.Level0)
|
||||
data2.AddRecord(record2);
|
||||
std::string bundleName2 = "com.example.myapplication";
|
||||
data2.SetOrginAuthority(bundleName2);
|
||||
|
||||
ASSERT_TRUE(data1.GetBundleName() == data2.GetBundleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetShareOption001
|
||||
* @tc.desc:
|
||||
* @tc.desc: GetShareOption call
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author:
|
||||
@ -881,7 +879,7 @@ HWTEST_F(PasteDataTest, GetShareOption001, TestSize.Level0)
|
||||
|
||||
/**
|
||||
* @tc.name: AddKvRecord001
|
||||
* @tc.desc:
|
||||
* @tc.desc: AddKvRecord call
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author:
|
||||
@ -898,7 +896,7 @@ HWTEST_F(PasteDataTest, AddKvRecord001, TestSize.Level0)
|
||||
|
||||
/**
|
||||
* @tc.name: GetProperty001
|
||||
* @tc.desc:
|
||||
* @tc.desc: GetProperty call
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author:
|
||||
@ -933,7 +931,7 @@ HWTEST_F(PasteDataTest, SetProperty001, TestSize.Level0)
|
||||
|
||||
/**
|
||||
* @tc.name: SetShareOption001
|
||||
* @tc.desc:
|
||||
* @tc.desc: SetShareOption call
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author:
|
||||
@ -969,7 +967,7 @@ HWTEST_F(PasteDataTest, SetTokenId001, TestSize.Level0)
|
||||
|
||||
/**
|
||||
* @tc.name: IsDraggedData001
|
||||
* @tc.desc:
|
||||
* @tc.desc: IsDraggedData call
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author:
|
||||
@ -987,7 +985,7 @@ HWTEST_F(PasteDataTest, IsDraggedData001, TestSize.Level0)
|
||||
|
||||
/**
|
||||
* @tc.name: SetDraggedDataFlag001
|
||||
* @tc.desc:
|
||||
* @tc.desc: SetDraggedDataFlag call
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
* @tc.author:
|
||||
|
@ -1623,44 +1623,6 @@ describe('PasteBoardJSTest', function () {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @tc.name pasteboard_promise_test58
|
||||
* @tc.desc test addEntry and getData
|
||||
* @tc.type Function
|
||||
* @tc.require AR000HEECD
|
||||
*/
|
||||
it('pasteboard_promise_test58', 0, async function (done) {
|
||||
const htmlText = "<html><head></head><body>Hello World!</body></html>";
|
||||
const plainData = "Hello World!";
|
||||
const uriText = "https://www.AACCSVDSVSDV.com/";
|
||||
const buffer58 = new ArrayBuffer(128);
|
||||
const opt58 = {
|
||||
size: { height: 5, width: 5 },
|
||||
pixelFormat: 3,
|
||||
editable: true,
|
||||
alphaType: 1,
|
||||
scaleMode: 1,
|
||||
};
|
||||
const pixelMap = await image.createPixelMap(buffer58, opt58);
|
||||
const pasteRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_HTML, htmlText);
|
||||
pasteRecord.addEntry(pasteboard.MIMETYPE_TEXT_PLAIN, plainData);
|
||||
pasteRecord.addEntry(pasteboard.MIMETYPE_TEXT_URI, uriText);
|
||||
pasteRecord.addEntry(pasteboard.MIMETYPE_PIXELMAP, pixelMap);
|
||||
|
||||
const html = await pasteRecord.getData(pasteboard.MIMETYPE_TEXT_HTML);
|
||||
expect(html.toString()).assertEqual(htmlText.toString());
|
||||
const plain = await pasteRecord.getData(pasteboard.MIMETYPE_TEXT_PLAIN);
|
||||
expect(plain.toString()).assertEqual(plainData.toString());
|
||||
const uri = await pasteRecord.getData(pasteboard.MIMETYPE_TEXT_URI);
|
||||
expect(uri.toString()).assertEqual(uriText.toString());
|
||||
const pixel = await pasteRecord.getData(pasteboard.MIMETYPE_PIXELMAP);
|
||||
const PixelMapBytesNumber = pixel.getPixelBytesNumber();
|
||||
expect(PixelMapBytesNumber).assertEqual(100);
|
||||
const imageInfo = await pixel.getImageInfo();
|
||||
expect(imageInfo.size.height === 5 && imageInfo.size.width === 5).assertEqual(true);
|
||||
|
||||
done();
|
||||
});
|
||||
/**
|
||||
* The callback function is used for pasteboard content changes
|
||||
*/
|
||||
|
@ -1313,9 +1313,9 @@ std::pair<bool, ClipPlugin::GlobalEvent> PasteboardService::GetValidDistributeEv
|
||||
Event evt;
|
||||
auto plugin = GetClipPlugin();
|
||||
if (plugin == nullptr) {
|
||||
PASTEBOARD_HILOGE(PASTEBOARD_MODULE_SERVICE, "plugin is nullptr.");
|
||||
return std::make_pair(false, evt);
|
||||
}
|
||||
|
||||
auto events = plugin->GetTopEvents(1, user);
|
||||
if (events.empty()) {
|
||||
PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "events empty.");
|
||||
@ -1397,6 +1397,7 @@ bool PasteboardService::IsRemoteData()
|
||||
{
|
||||
auto userId = GetCurrentAccountId();
|
||||
if (userId == ERROR_USERID) {
|
||||
PASTEBOARD_HILOGE(PASTEBOARD_MODULE_SERVICE, "userId is error.");
|
||||
return false;
|
||||
}
|
||||
auto it = clips_.Find(userId);
|
||||
@ -1940,6 +1941,7 @@ void PasteboardService::GetPasteDataDot(PasteData &pasteData, const std::string
|
||||
std::string time = GetTime();
|
||||
HistoryInfo info{ time, bundleName, "get", remote };
|
||||
SetPasteboardHistory(info);
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_SERVICE, "GetPasteData Report!");
|
||||
int pState = StatisticPasteboardState::SPS_INVALID_STATE;
|
||||
int bState = BehaviourPasteboardState::BPS_INVALID_STATE;
|
||||
if (pasteData.IsRemote()) {
|
||||
@ -1951,7 +1953,6 @@ void PasteboardService::GetPasteDataDot(PasteData &pasteData, const std::string
|
||||
};
|
||||
|
||||
Reporter::GetInstance().PasteboardBehaviour().Report({ bState, bundleName });
|
||||
|
||||
size_t dataSize = GetDataSize(pasteData);
|
||||
CalculateTimeConsuming timeC(dataSize, pState);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。"
|
||||
}
|
||||
]
|
||||
"string":[
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"སྒྲིག་ཆས་གཅིག་གི་ཐོག་ཏུ་འདྲ་བཤུ་བྱས་རྗེས། ཉེ་འགྲམ་གྱི་ཧྭ་ཝེ་ཐོ་ཨང་གཅིག་པ་ཐོ་འཇུག་བྱས་ཡོད་པའི་སྒྲིག་ཆས་ཐོག་ཏུ་སྦྱར་ཆོག རྩོལ་ནུས་འདི་བཀོལ་སྤྱོད་བྱ་བར་ཕྱོགས་གཉིས་པོས་༼སྒྲིག་ཆས་བརྒལ་བའི་དྲས་སྦྱར་པང་༽དང་ WLAN སོ་སྔོན་བཅས་ཁ་འབྱེད་དགོས།"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。"
|
||||
}
|
||||
]
|
||||
"string":[
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"Copy on one device, paste on another.\n\nDevices need to be close to each other, have this feature, WLAN, and Bluetooth enabled, and be using the same ID."
|
||||
}
|
||||
]
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。"
|
||||
}
|
||||
]
|
||||
"string":[
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"بىر ئۈسكۈنىدە كۆچۈرگەن مەزمۇننى ئەتراپتىكى ئوخشاش خۇاۋېي ھېسابىغا تىزىملاپ كىرگەن يەنە بىر ئۈسكۈنىدە چاپلاشقا بولىدۇ. ھەر ئىككى ئۈسكۈنىدە «ئۈسكۈنىلەر ئارا كېسىش تاختىسى»، WLAN ۋە كۆكچىش ئوچۇق بولۇشى كېرەك."
|
||||
}
|
||||
]
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台设备上进行复制,然后可在附近另一台登录相同账号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。"
|
||||
}
|
||||
]
|
||||
"string":[
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台设备上进行复制,然后可在附近另一台登录相同账号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。"
|
||||
}
|
||||
]
|
||||
"string":[
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台裝置上進行複製,然後可以在附近另一台登入相同 ID 的裝置中貼上。此功能需要兩台裝置皆已啟用「跨裝置剪貼簿」、WLAN 和藍牙。"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。"
|
||||
}
|
||||
]
|
||||
"string": [
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台裝置中進行複製,然後可以在附近另一台登入相同 ID 的裝置中貼上。此功能需要兩台裝置皆已啟用「跨裝置剪貼簿」、WLAN 和藍牙。"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,48 +1,44 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "entry_desc",
|
||||
"value": "Pasteboard dialog"
|
||||
},
|
||||
{
|
||||
"name": "ToastExtensionAbility_desc",
|
||||
"value": "Pasteboard toast extension"
|
||||
},
|
||||
{
|
||||
"name": "ToastExtensionAbility_label",
|
||||
"value": "Pasteboard Toast"
|
||||
},
|
||||
{
|
||||
"name": "typeface",
|
||||
"value": "HarmonyHeiTi"
|
||||
},
|
||||
{
|
||||
"name": "info",
|
||||
"value": "读取了剪贴板信息"
|
||||
},
|
||||
{
|
||||
"name":"PasteboardSwitchAbility_desc",
|
||||
"value":"description"
|
||||
},
|
||||
{
|
||||
"name":"PasteboardSwitchAbility_label",
|
||||
"value":"label"
|
||||
},
|
||||
{
|
||||
"name":"pasteboard_title",
|
||||
"value":"跨设备剪贴板"
|
||||
},
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙."
|
||||
},
|
||||
{
|
||||
"name": "multi_device_collaboration",
|
||||
"value": "多设备协同"
|
||||
},
|
||||
{
|
||||
"name": "update_version_prompt",
|
||||
"value": "对方需升级至 HarmonyOS NEXT 及以上版本。"
|
||||
}
|
||||
]
|
||||
"string":[
|
||||
{
|
||||
"name":"entry_desc",
|
||||
"value":"Pasteboard dialog"
|
||||
},
|
||||
{
|
||||
"name":"ToastExtensionAbility_desc",
|
||||
"value":"Pasteboard toast extension"
|
||||
},
|
||||
{
|
||||
"name":"ToastExtensionAbility_label",
|
||||
"value":"Pasteboard Toast"
|
||||
},
|
||||
{
|
||||
"name":"typeface",
|
||||
"value":"HarmonyHeiTi"
|
||||
},
|
||||
{
|
||||
"name":"PasteboardSwitchAbility_desc",
|
||||
"value":"description"
|
||||
},
|
||||
{
|
||||
"name":"PasteboardSwitchAbility_label",
|
||||
"value":"label"
|
||||
},
|
||||
{
|
||||
"name":"pasteboard_title",
|
||||
"value":"跨设备剪贴板"
|
||||
},
|
||||
{
|
||||
"name":"pasteboard_desc",
|
||||
"value":"在一台设备上进行复制,然后可在附近另一台登录相同账号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙."
|
||||
},
|
||||
{
|
||||
"name":"multi_device_collaboration",
|
||||
"value":"多设备协同"
|
||||
},
|
||||
{
|
||||
"name":"update_version_prompt",
|
||||
"value":"对方需升级至 HarmonyOS NEXT 及以上版本。"
|
||||
}
|
||||
]
|
||||
}
|
@ -59,7 +59,6 @@ ohos_unittest("PasteboardServiceTest") {
|
||||
"image_framework:image_native",
|
||||
"ipc:ipc_core",
|
||||
"os_account:os_account_innerkits",
|
||||
"udmf:udmf_client",
|
||||
]
|
||||
|
||||
deps = [
|
||||
@ -77,6 +76,7 @@ ohos_unittest("PasteboardDialogNormalTest") {
|
||||
]
|
||||
configs = [ ":module_private_config" ]
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_manager",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
@ -95,6 +95,7 @@ ohos_unittest("PasteboardDialogAbnormalTest") {
|
||||
]
|
||||
configs = [ ":module_private_config" ]
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_manager",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
|
@ -305,6 +305,8 @@ HWTEST_F(PasteboardServiceTest, PasteRecordTest005, TestSize.Level0)
|
||||
ASSERT_TRUE(imageInfo.size.height == opts.size.height);
|
||||
ASSERT_TRUE(imageInfo.size.width == opts.size.width);
|
||||
ASSERT_TRUE(imageInfo.pixelFormat == opts.pixelFormat);
|
||||
pasteDataRecord->ClearPixelMap();
|
||||
ASSERT_TRUE(pasteDataRecord->GetPixelMap() == nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,19 +31,6 @@ T TypeCast(const uint8_t *data, int *pos = nullptr)
|
||||
return *(reinterpret_cast<const T*>(data));
|
||||
}
|
||||
|
||||
bool FuzzFfrtUtilsSubmitTask(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
if (rawData == nullptr || size < sizeof(int32_t)) {
|
||||
return true;
|
||||
}
|
||||
int x = TypeCast<int32_t>(rawData, nullptr);
|
||||
FFRTTask task = [&] {
|
||||
x /= 2;
|
||||
};
|
||||
FFRTUtils::SubmitTask(task);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FuzzFfrtUtilsSubmitQueueTasks(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
if (rawData == nullptr || size < sizeof(int32_t) + sizeof(int32_t)) {
|
||||
@ -58,11 +45,15 @@ bool FuzzFfrtUtilsSubmitQueueTasks(const uint8_t *rawData, size_t size)
|
||||
FFRTTask task1 = [&] {
|
||||
y /= 2;
|
||||
};
|
||||
std::vector<FFRTTask> tasks;
|
||||
tasks.push_back(task);
|
||||
tasks.push_back(task1);
|
||||
FFRTQueue serialQueue("pasteboard_queue");
|
||||
FFRTUtils::SubmitQueueTasks(tasks, serialQueue);
|
||||
static uint32_t thresHold = 1;
|
||||
if (thresHold <= 1) {
|
||||
std::vector<FFRTTask> tasks;
|
||||
tasks.push_back(task);
|
||||
tasks.push_back(task1);
|
||||
FFRTQueue serialQueue("pasteboard_queue");
|
||||
FFRTUtils::SubmitQueueTasks(tasks, serialQueue);
|
||||
thresHold++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -71,14 +62,17 @@ bool FuzzFfrtUtilsSubmitDelayTask(const uint8_t *rawData, size_t size)
|
||||
if (rawData == nullptr || size < sizeof(int32_t)) {
|
||||
return true;
|
||||
}
|
||||
int y = TypeCast<int32_t>(rawData);
|
||||
FFRTTask task = [&] {
|
||||
y /= 2;
|
||||
};
|
||||
uint32_t delayMs = 5; // delay 5Ms
|
||||
FFRTQueue serQueue("delaytask_queue");
|
||||
FFRTHandle ffrtHandle = FFRTUtils::SubmitDelayTask(task, delayMs, serQueue);
|
||||
FFRTUtils::CancelTask(ffrtHandle, serQueue);
|
||||
static uint32_t thresHold = 1;
|
||||
if (thresHold <= 1) {
|
||||
int y = TypeCast<int32_t>(rawData);
|
||||
FFRTTask task = [&] {
|
||||
y /= 2;
|
||||
};
|
||||
uint32_t delayMs = 5; // delay 5Ms
|
||||
FFRTQueue serQueue("delaytask_queue");
|
||||
FFRTUtils::SubmitDelayTask(task, delayMs, serQueue);
|
||||
thresHold++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -92,9 +86,12 @@ bool FuzzUtilsSubmitDelayTask(const uint8_t *rawData, size_t size)
|
||||
z /= 2;
|
||||
};
|
||||
uint32_t delayMs = 5; // delay 5Ms
|
||||
shared_ptr<FFRTQueue> queue = make_shared<FFRTQueue>("delaytask_queue_ptr");
|
||||
FFRTHandle ffrtHandle = FFRTUtils::SubmitDelayTask(task, delayMs, queue);
|
||||
FFRTUtils::CancelTask(ffrtHandle, queue);
|
||||
static uint32_t thresHold = 1;
|
||||
if (thresHold <= 1) {
|
||||
shared_ptr<FFRTQueue> queue = make_shared<FFRTQueue>("delaytask_queue_ptr");
|
||||
FFRTUtils::SubmitDelayTask(task, delayMs, queue);
|
||||
thresHold++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -107,8 +104,12 @@ bool FuzzUtilsSubmitTimeoutTask(const uint8_t *rawData, size_t size)
|
||||
FFRTTask task = [&] {
|
||||
m /= 2;
|
||||
};
|
||||
uint32_t timeout = 10; // timeout 10Ms
|
||||
FFRTUtils::SubmitTimeoutTask(task, timeout);
|
||||
static uint32_t thresHold = 1;
|
||||
if (thresHold <= 1) {
|
||||
uint32_t timeout = 10; // timeout 10Ms
|
||||
FFRTUtils::SubmitTimeoutTask(task, timeout);
|
||||
thresHold++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -140,13 +141,17 @@ bool FuzzFfRTTimerMultiSetAndCancel(const uint8_t *rawData, size_t size)
|
||||
n = 5;
|
||||
};
|
||||
int len = size >> 1;
|
||||
string timerId1(reinterpret_cast<const char*>(rawData), len);
|
||||
string timerId2(reinterpret_cast<const char*>(rawData + len), size - len);
|
||||
FFRTTimer ffrtTimer("fuzz_test_timername");
|
||||
uint32_t delayMs = 5; // delay 5Ms
|
||||
ffrtTimer.SetTimer(timerId1, task, delayMs);
|
||||
ffrtTimer.SetTimer(timerId2, task1, delayMs);
|
||||
ffrtTimer.CancelAllTimer();
|
||||
string timerId1 = "TimerMultiSetAndCancel1";
|
||||
string timerId2 = "TimerMultiSetAndCancel2";
|
||||
static uint32_t thresHold = 1;
|
||||
if (thresHold <= 1) {
|
||||
FFRTTimer ffrtTimer("fuzz_test_timername");
|
||||
uint32_t delayMs = 5; // delay 5Ms
|
||||
ffrtTimer.SetTimer(timerId1, task, delayMs);
|
||||
ffrtTimer.SetTimer(timerId2, task1, delayMs);
|
||||
ffrtTimer.CancelAllTimer();
|
||||
thresHold++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS
|
||||
@ -154,13 +159,11 @@ bool FuzzFfRTTimerMultiSetAndCancel(const uint8_t *rawData, size_t size)
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::FuzzFfrtUtilsSubmitTask(data, size);
|
||||
OHOS::FuzzFfrtUtilsSubmitQueueTasks(data, size);
|
||||
OHOS::FuzzFfrtUtilsSubmitDelayTask(data, size);
|
||||
OHOS::FuzzUtilsSubmitDelayTask(data, size);
|
||||
OHOS::FuzzUtilsSubmitTimeoutTask(data, size);
|
||||
OHOS::FuzzFfRTTimerSingleSetAndCancel(data, size);
|
||||
OHOS::FuzzFfRTTimerSingleSetAndCancel(data, size);
|
||||
OHOS::FuzzFfRTTimerMultiSetAndCancel(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ ohos_fuzztest("PasteboardClientFuzzTest") {
|
||||
"hilog:libhilog",
|
||||
"image_framework:image_native",
|
||||
"ipc:ipc_core",
|
||||
"udmf:udmf_client",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,9 @@ void FuzzPasteboard(const uint8_t *rawData, size_t size)
|
||||
if (PasteboardClient::GetInstance()->HasPasteData()) {
|
||||
PasteboardClient::GetInstance()->RemovePasteboardChangedObserver(nullptr);
|
||||
}
|
||||
PasteboardClient::GetInstance()->SetPasteData(*pasteData);
|
||||
std::set<Pattern> patternsToCheck = {Pattern::URL, Pattern::EmailAddress, static_cast<Pattern>(code)};
|
||||
PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck);
|
||||
}
|
||||
|
||||
void FuzzPastedata(const uint8_t *rawData, size_t size)
|
||||
|
@ -26,6 +26,8 @@
|
||||
namespace OHOS {
|
||||
using namespace OHOS::Security::PasteboardServ;
|
||||
using namespace OHOS::MiscServices;
|
||||
constexpr size_t THRESHOLD = 2;
|
||||
const std::u16string PASTEBOARDSERVICE_INTERFACE_TOKEN = u"ohos.miscservices.pasteboard.IPasteboardService";
|
||||
|
||||
template<class T>
|
||||
T TypeCast(const uint8_t *data, int *pos = nullptr)
|
||||
@ -36,6 +38,21 @@ T TypeCast(const uint8_t *data, int *pos = nullptr)
|
||||
return *(reinterpret_cast<const T*>(data));
|
||||
}
|
||||
|
||||
bool FuzzPasteboardObserver(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
if (rawData == nullptr || size < sizeof(uint32_t)) {
|
||||
return true;
|
||||
}
|
||||
uint32_t code = TypeCast<uint32_t>(rawData);
|
||||
MessageParcel data;
|
||||
data.WriteInterfaceToken(PASTEBOARDSERVICE_INTERFACE_TOKEN);
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
std::make_shared<PasteboardObserver>()->OnRemoteRequest(
|
||||
static_cast<uint32_t>(code % THRESHOLD), data, reply, option);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FuzzPasteboardObserverOnPasteboardChangedStub(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -70,6 +87,7 @@ bool FuzzPasteboardObserverOnPasteboardEventStub(const uint8_t *rawData, size_t
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::FuzzPasteboardObserver(data, size);
|
||||
OHOS::FuzzPasteboardObserverOnPasteboardChangedStub(data, size);
|
||||
OHOS::FuzzPasteboardObserverOnPasteboardEventStub(data, size);
|
||||
return 0;
|
||||
|
@ -72,7 +72,6 @@ ohos_fuzztest("PasteboardServiceFuzzTest") {
|
||||
"ipc:ipc_core",
|
||||
"os_account:os_account_innerkits",
|
||||
"safwk:system_ability_fwk",
|
||||
"udmf:udmf_client",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,7 @@ ohos_fuzztest("UriHandlerFuzzTest") {
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"${pasteboard_root_path}/framework/uri/copy_uri_handler.cpp",
|
||||
"${pasteboard_root_path}/framework/uri/paste_uri_handler.cpp",
|
||||
"${pasteboard_root_path}/framework/uri/uri_handler.cpp",
|
||||
"urihandler_fuzzer.cpp",
|
||||
]
|
||||
sources = [ "urihandler_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${pasteboard_innerkits_path}:pasteboard_client",
|
||||
|
@ -62,10 +62,20 @@ bool FuzzPasteUriHandlerToUri(const uint8_t *rawData, size_t size)
|
||||
return true;
|
||||
}
|
||||
int32_t fd = TypeCast<int32_t>(rawData, nullptr);
|
||||
if (fd >= 0) {
|
||||
return true;
|
||||
}
|
||||
PasteUriHandler pasteUriHandler;
|
||||
(void)pasteUriHandler.ToUri(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FuzzPasteUriHandlerIsPaste(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
PasteUriHandler pasteUriHandler;
|
||||
(void)pasteUriHandler.IsPaste();
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
@ -75,5 +85,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
OHOS::FuzzUriToFd(data, size);
|
||||
OHOS::FuzzCopyUriHandlerToUri(data, size);
|
||||
OHOS::FuzzPasteUriHandlerToUri(data, size);
|
||||
OHOS::FuzzPasteUriHandlerIsPaste(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user