diff --git a/.gitattributes b/.gitattributes index 51c63e29..e69de29b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/etc/init/pasteboardservice.cfg b/etc/init/pasteboardservice.cfg index cc0fe2be..1f458881 100644 --- a/etc/init/pasteboardservice.cfg +++ b/etc/init/pasteboardservice.cfg @@ -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" : { diff --git a/framework/innerkits/include/paste_data.h b/framework/innerkits/include/paste_data.h index 460dbb4b..c14c6c71 100644 --- a/framework/innerkits/include/paste_data.h +++ b/framework/innerkits/include/paste_data.h @@ -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> records_; std::string orginAuthority_; diff --git a/framework/test/src/paste_data_test.cpp b/framework/test/src/paste_data_test.cpp index 8dd5bc87..169fb57b 100644 --- a/framework/test/src/paste_data_test.cpp +++ b/framework/test/src/paste_data_test.cpp @@ -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: diff --git a/interfaces/kits/napi/test/unittest/pasteboardapi/PasteBoardPromiseJsunit.test.js b/interfaces/kits/napi/test/unittest/pasteboardapi/PasteBoardPromiseJsunit.test.js index 9913926e..cc985a2b 100644 --- a/interfaces/kits/napi/test/unittest/pasteboardapi/PasteBoardPromiseJsunit.test.js +++ b/interfaces/kits/napi/test/unittest/pasteboardapi/PasteBoardPromiseJsunit.test.js @@ -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 = "Hello World!"; - 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 */ diff --git a/services/core/src/pasteboard_service.cpp b/services/core/src/pasteboard_service.cpp index 7eb7395f..2e0be9d8 100644 --- a/services/core/src/pasteboard_service.cpp +++ b/services/core/src/pasteboard_service.cpp @@ -1313,9 +1313,9 @@ std::pair 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); } diff --git a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-bo_CN/element/string.json b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-bo_CN/element/string.json index 80e4d688..c671a40c 100644 --- a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-bo_CN/element/string.json +++ b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-bo_CN/element/string.json @@ -1,8 +1,8 @@ { - "string": [ - { - "name":"pasteboard_desc", - "value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。" - } - ] + "string":[ + { + "name":"pasteboard_desc", + "value":"སྒྲིག་ཆས་གཅིག་གི་ཐོག་ཏུ་འདྲ་བཤུ་བྱས་རྗེས། ཉེ་འགྲམ་གྱི་ཧྭ་ཝེ་ཐོ་ཨང་གཅིག་པ་ཐོ་འཇུག་བྱས་ཡོད་པའི་སྒྲིག་ཆས་ཐོག་ཏུ་སྦྱར་ཆོག རྩོལ་ནུས་འདི་བཀོལ་སྤྱོད་བྱ་བར་ཕྱོགས་གཉིས་པོས་༼སྒྲིག་ཆས་བརྒལ་བའི་དྲས་སྦྱར་པང་༽དང་ WLAN སོ་སྔོན་བཅས་ཁ་འབྱེད་དགོས།" + } + ] } \ No newline at end of file diff --git a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-en/element/string.json b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-en/element/string.json index 80e4d688..ef7cbdd3 100644 --- a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-en/element/string.json +++ b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-en/element/string.json @@ -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." + } + ] } \ No newline at end of file diff --git a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-ug/element/string.json b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-ug/element/string.json index 80e4d688..03211ce6 100644 --- a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-ug/element/string.json +++ b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-ug/element/string.json @@ -1,8 +1,8 @@ { - "string": [ - { - "name":"pasteboard_desc", - "value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。" - } - ] + "string":[ + { + "name":"pasteboard_desc", + "value":"بىر ئۈسكۈنىدە كۆچۈرگەن مەزمۇننى ئەتراپتىكى ئوخشاش خۇاۋېي ھېسابىغا تىزىملاپ كىرگەن يەنە بىر ئۈسكۈنىدە چاپلاشقا بولىدۇ. ھەر ئىككى ئۈسكۈنىدە «ئۈسكۈنىلەر ئارا كېسىش تاختىسى»، WLAN ۋە كۆكچىش ئوچۇق بولۇشى كېرەك." + } + ] } \ No newline at end of file diff --git a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_CN/element/string.json b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_CN/element/string.json index 76ad170c..23a010e9 100644 --- a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_CN/element/string.json +++ b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_CN/element/string.json @@ -1,8 +1,8 @@ { - "string": [ - { - "name":"pasteboard_desc", - "value":"在一台设备上进行复制,然后可在附近另一台登录相同账号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。" - } - ] + "string":[ + { + "name":"pasteboard_desc", + "value":"在一台设备上进行复制,然后可在附近另一台登录相同账号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。" + } + ] } \ No newline at end of file diff --git a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_HK/element/string.json b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_HK/element/string.json index 80e4d688..9fdcfc2e 100644 --- a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_HK/element/string.json +++ b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_HK/element/string.json @@ -1,8 +1,8 @@ { - "string": [ - { - "name":"pasteboard_desc", - "value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。" - } - ] + "string":[ + { + "name":"pasteboard_desc", + "value":"在一台裝置上進行複製,然後可以在附近另一台登入相同 ID 的裝置中貼上。此功能需要兩台裝置皆已啟用「跨裝置剪貼簿」、WLAN 和藍牙。" + } + ] } \ No newline at end of file diff --git a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_TW/element/string.json b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_TW/element/string.json index 80e4d688..1934654c 100644 --- a/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_TW/element/string.json +++ b/services/dialog/PasteboardDialog/entry/src/main/resources/mcc460-zh_TW/element/string.json @@ -1,8 +1,8 @@ { - "string": [ - { - "name":"pasteboard_desc", - "value":"在一台设备上进行复制,然后可在附近另一台登录相同帐号的设备上粘贴。此功能需双方设备开启“跨设备剪贴板”、WLAN和蓝牙。" - } - ] + "string": [ + { + "name":"pasteboard_desc", + "value":"在一台裝置中進行複製,然後可以在附近另一台登入相同 ID 的裝置中貼上。此功能需要兩台裝置皆已啟用「跨裝置剪貼簿」、WLAN 和藍牙。" + } + ] } \ No newline at end of file diff --git a/services/dialog/PasteboardDialog/entry/src/main/resources/zh_CN/element/string.json b/services/dialog/PasteboardDialog/entry/src/main/resources/zh_CN/element/string.json index ae4f1fb6..46ac2acd 100644 --- a/services/dialog/PasteboardDialog/entry/src/main/resources/zh_CN/element/string.json +++ b/services/dialog/PasteboardDialog/entry/src/main/resources/zh_CN/element/string.json @@ -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 及以上版本。" + } + ] } \ No newline at end of file diff --git a/services/test/BUILD.gn b/services/test/BUILD.gn index 640eadaa..b617608d 100644 --- a/services/test/BUILD.gn +++ b/services/test/BUILD.gn @@ -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", diff --git a/services/test/unittest/src/paste_service_test.cpp b/services/test/unittest/src/paste_service_test.cpp index 341477cf..7b99fb3f 100644 --- a/services/test/unittest/src/paste_service_test.cpp +++ b/services/test/unittest/src/paste_service_test.cpp @@ -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); } /** diff --git a/test/fuzztest/ffrtutils_fuzzer/ffrtutils_fuzzer.cpp b/test/fuzztest/ffrtutils_fuzzer/ffrtutils_fuzzer.cpp index 7e2d95e0..27477144 100644 --- a/test/fuzztest/ffrtutils_fuzzer/ffrtutils_fuzzer.cpp +++ b/test/fuzztest/ffrtutils_fuzzer/ffrtutils_fuzzer.cpp @@ -31,19 +31,6 @@ T TypeCast(const uint8_t *data, int *pos = nullptr) return *(reinterpret_cast(data)); } -bool FuzzFfrtUtilsSubmitTask(const uint8_t *rawData, size_t size) -{ - if (rawData == nullptr || size < sizeof(int32_t)) { - return true; - } - int x = TypeCast(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 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 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(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(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 queue = make_shared("delaytask_queue_ptr"); - FFRTHandle ffrtHandle = FFRTUtils::SubmitDelayTask(task, delayMs, queue); - FFRTUtils::CancelTask(ffrtHandle, queue); + static uint32_t thresHold = 1; + if (thresHold <= 1) { + shared_ptr queue = make_shared("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(rawData), len); - string timerId2(reinterpret_cast(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; } diff --git a/test/fuzztest/pasteboardclient_fuzzer/BUILD.gn b/test/fuzztest/pasteboardclient_fuzzer/BUILD.gn index a6f809b0..98179360 100644 --- a/test/fuzztest/pasteboardclient_fuzzer/BUILD.gn +++ b/test/fuzztest/pasteboardclient_fuzzer/BUILD.gn @@ -52,7 +52,6 @@ ohos_fuzztest("PasteboardClientFuzzTest") { "hilog:libhilog", "image_framework:image_native", "ipc:ipc_core", - "udmf:udmf_client", ] } diff --git a/test/fuzztest/pasteboardclient_fuzzer/pasteboardclient_fuzzer.cpp b/test/fuzztest/pasteboardclient_fuzzer/pasteboardclient_fuzzer.cpp index 43d09428..a95e8754 100644 --- a/test/fuzztest/pasteboardclient_fuzzer/pasteboardclient_fuzzer.cpp +++ b/test/fuzztest/pasteboardclient_fuzzer/pasteboardclient_fuzzer.cpp @@ -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 patternsToCheck = {Pattern::URL, Pattern::EmailAddress, static_cast(code)}; + PasteboardClient::GetInstance()->DetectPatterns(patternsToCheck); } void FuzzPastedata(const uint8_t *rawData, size_t size) diff --git a/test/fuzztest/pasteboardobserver_fuzzer/pasteboardobserver_fuzzer.cpp b/test/fuzztest/pasteboardobserver_fuzzer/pasteboardobserver_fuzzer.cpp index 87357ca0..e5fa64fa 100644 --- a/test/fuzztest/pasteboardobserver_fuzzer/pasteboardobserver_fuzzer.cpp +++ b/test/fuzztest/pasteboardobserver_fuzzer/pasteboardobserver_fuzzer.cpp @@ -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 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(data)); } +bool FuzzPasteboardObserver(const uint8_t *rawData, size_t size) +{ + if (rawData == nullptr || size < sizeof(uint32_t)) { + return true; + } + uint32_t code = TypeCast(rawData); + MessageParcel data; + data.WriteInterfaceToken(PASTEBOARDSERVICE_INTERFACE_TOKEN); + MessageParcel reply; + MessageOption option; + std::make_shared()->OnRemoteRequest( + static_cast(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; diff --git a/test/fuzztest/pasteboardservice_fuzzer/BUILD.gn b/test/fuzztest/pasteboardservice_fuzzer/BUILD.gn index 25abd11f..ab3213f1 100644 --- a/test/fuzztest/pasteboardservice_fuzzer/BUILD.gn +++ b/test/fuzztest/pasteboardservice_fuzzer/BUILD.gn @@ -72,7 +72,6 @@ ohos_fuzztest("PasteboardServiceFuzzTest") { "ipc:ipc_core", "os_account:os_account_innerkits", "safwk:system_ability_fwk", - "udmf:udmf_client", ] } diff --git a/test/fuzztest/urihandler_fuzzer/BUILD.gn b/test/fuzztest/urihandler_fuzzer/BUILD.gn index d0ea364a..467b4226 100644 --- a/test/fuzztest/urihandler_fuzzer/BUILD.gn +++ b/test/fuzztest/urihandler_fuzzer/BUILD.gn @@ -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", diff --git a/test/fuzztest/urihandler_fuzzer/urihandler_fuzzer.cpp b/test/fuzztest/urihandler_fuzzer/urihandler_fuzzer.cpp index 1abe9e15..8e0a74c2 100644 --- a/test/fuzztest/urihandler_fuzzer/urihandler_fuzzer.cpp +++ b/test/fuzztest/urihandler_fuzzer/urihandler_fuzzer.cpp @@ -62,10 +62,20 @@ bool FuzzPasteUriHandlerToUri(const uint8_t *rawData, size_t size) return true; } int32_t fd = TypeCast(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; }