From da0feae7abc9bb9611bf165ef6307c0550ff39cc Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Mon, 25 Apr 2022 15:51:56 +0800 Subject: [PATCH 1/5] add screen fuzz test Signed-off-by: qinlong0101 --- .../dscreensourceproxy_fuzzer/BUILD.gn | 78 ++++++++++++++++++ .../corpus/init} | 10 +-- .../dscreen_source_proxy_fuzzer.cpp | 75 +++++++++++++++++ .../dscreen_source_proxy_fuzzer.h | 24 ++++++ .../dscreensourceproxy_fuzzer/project.xml | 25 ++++++ .../screentransport/test/fuzztest/BUILD.gn | 4 +- .../screensinkprocessor_fuzzer/BUILD.gn | 81 ++++++++++++++++++ .../screensinkprocessor_fuzzer/corpus/init | 14 ++++ .../screensinkprocessor_fuzzer/project.xml | 25 ++++++ .../screen_sink_processor_fuzzer.cpp | 65 +++++++++++++++ .../screen_sink_processor_fuzzer.h | 21 +++++ .../fuzztest/screensinktrans_fuzzer/BUILD.gn | 82 +++++++++++++++++++ .../screensinktrans_fuzzer/corpus/init | 1 + .../screensinktrans_fuzzer/project.xml | 25 ++++++ .../screen_sink_trans_fuzzer.cpp | 69 ++++++++++++++++ .../screen_sink_trans_fuzzer.h | 21 +++++ 16 files changed, 610 insertions(+), 10 deletions(-) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn rename interfaces/innerkits/native_cpp/test/fuzztest/{BUILD.gn => dscreensourceproxy_fuzzer/corpus/init} (76%) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/project.xml create mode 100644 services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn create mode 100644 services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/corpus/init create mode 100644 services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/project.xml create mode 100644 services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.cpp create mode 100644 services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.h create mode 100644 services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn create mode 100644 services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init create mode 100644 services/screentransport/test/fuzztest/screensinktrans_fuzzer/project.xml create mode 100644 services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp create mode 100644 services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.h diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn new file mode 100644 index 00000000..a220e7fd --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn @@ -0,0 +1,78 @@ +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DscreenSourceProxyFuzzTest") { + module_out_path = "distributed_screen/dscreensourceproxy" + + fuzz_config_file = + "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "dscreen_source_proxy_fuzzer.cpp", + ] + + deps = [ + "//utils/native/base:utils", + "${common_path}:distributed_screen_utils", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DscreenSourceProxyFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":DscreenSourceProxyFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/corpus/init similarity index 76% rename from interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/corpus/init index fd6ed3ee..bc977bd9 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/corpus/init @@ -11,12 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -group("fuzztest") { - testonly = true - - deps = [ - "dscreensinkhandler_fuzzer:fuzztest", - "dscreensinkproxy_fuzzer:fuzztest", - "dscreensourcehandler_fuzzer:fuzztest", - ] -} +FUZZ \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp new file mode 100644 index 00000000..b52b412e --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp @@ -0,0 +1,75 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dscreen_source_proxy_fuzzer.h" + +#include +#include + +#include "dscreen_constants.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { + +void DscreenSourceProxyHandlerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string params(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string devId(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + std::string key(reinterpret_cast(data), size); + std::string value(reinterpret_cast(data), size); + int32_t eventCode = *(reinterpret_cast(data)); + std::string eventContent(reinterpret_cast(data), size); + std::string str(reinterpret_cast(data), size); + EnableParam param; + param.version = str; + param.attrs = str; + sptr callback = new DScreenSourceCallback(); + if (callback == nullptr) + { + return; + } + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + std::shared_ptr dscreenSourceProxy = std::make_shared(remoteObject); + + dscreenSourceProxy->InitSource(params, callback); + dscreenSourceProxy->ReleaseSource(); + dscreenSourceProxy->RegisterDistributedHardware(devId, dhId, param, reqId); + dscreenSourceProxy->UnregisterDistributedHardware(devId, dhId, reqId); + dscreenSourceProxy->ConfigDistributedHardware(devId, dhId, key, value); + dscreenSourceProxy->DScreenNotify(devId, eventCode, eventContent); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::DscreenSourceProxyHandlerFuzzTest(data, size); + return 0; +} diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h new file mode 100644 index 00000000..2b4e44b6 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DSCREEN_SOURCE_PROXY_FUZZER_H +#define DSCREEN_SOURCE_PROXY_FUZZER_H + +#define FUZZ_PROJECT_NAME "dscreen_source_proxy_fuzzer" + +#endif + + + diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/BUILD.gn b/services/screentransport/test/fuzztest/BUILD.gn index 02b6da6b..a3656fce 100644 --- a/services/screentransport/test/fuzztest/BUILD.gn +++ b/services/screentransport/test/fuzztest/BUILD.gn @@ -18,5 +18,7 @@ group("fuzztest") { "screendatachannel_fuzzer:fuzztest", "screensourceprocessor_fuzzer:fuzztest", "screensourcetrans_fuzzer:fuzztest", + "screensinktrans_fuzzer:fuzztest", + "screensinkprocessor_fuzzer:fuzztest" ] -} +} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn new file mode 100644 index 00000000..7b4b1cb2 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn @@ -0,0 +1,81 @@ +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ScreenSinkProcessorFuzzTest") { + module_out_path = "distributed_screen/screensinkprocessor" + + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensinkprocessor_fuzzer" + + include_dirs = [ + "//third_party/json/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "./include", + "${services_path}/screentransport/test/unittest/screentranstestutils/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/softbusadapter/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "screen_sink_processor_fuzzer.cpp" ] + + deps = [ + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${fwk_utils_path}:distributedhardwareutils", + "//foundation/graphic/standard/frameworks/surface:surface", + "//utils/native/base:utils", + ] + + external_deps = [ + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + "multimedia_media_standard:media_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"ScreenSinkProcessorFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ScreenSinkProcessorFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/corpus/init new file mode 100644 index 00000000..bc977bd9 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.cpp b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.cpp new file mode 100644 index 00000000..06e36069 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.cpp @@ -0,0 +1,65 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "screen_sink_processor_fuzzer.h" + +#include +#include +#include + +#include "image_sink_processor.h" +#include "screen_sink_trans.h" + +namespace OHOS { +namespace DistributedHardware { +void ScreenSinkProcessorFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::shared_ptr imageSinkProcessor = std::make_shared(); + std::shared_ptr param = std::make_shared(); + uint32_t screenWidth = *(reinterpret_cast(data)); + uint32_t screenHeight = *(reinterpret_cast(data)); + uint32_t videoWidth = *(reinterpret_cast(data)); + uint32_t videoHeight = *(reinterpret_cast(data)); + param->SetScreenWidth(screenWidth); + param->SetScreenHeight(screenHeight); + param->SetVideoWidth(videoWidth); + param->SetScreenHeight(videoHeight); + std::shared_ptr imageListener = std::make_shared(); + std::string name(reinterpret_cast(data), size); + sptr surface = Surface::CreateSurfaceAsConsumer(name); + size_t capacity = size; + std::shared_ptr screenData = std::make_shared(capacity); + + imageSinkProcessor->SetImageSurface(surface); + imageSinkProcessor->ConfigureImageProcessor(*param, *param, imageListener); + imageSinkProcessor->ProcessImage(screenData); + imageSinkProcessor->StartImageProcessor(); + imageSinkProcessor->StopImageProcessor(); + imageSinkProcessor->ReleaseImageProcessor(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ScreenSinkProcessorFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.h b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.h new file mode 100644 index 00000000..e56562c9 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SCREEN_SINK_PROCESSOR_FUZZER_H +#define SCREEN_SINK_PROCESSOR_FUZZER_H + +#define FUZZ_PROJECT_NAME "screen_sink_processor_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn new file mode 100644 index 00000000..1ea6bd0a --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn @@ -0,0 +1,82 @@ +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ScreenSinkTransFuzzTest") { + module_out_path = "distributed_screen/screensinktrans" + + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensinktrans_fuzzer" + + include_dirs = [ + "//third_party/json/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "./include", + "${services_path}/screentransport/test/unittest/screentranstestutils/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/softbusadapter/include", + "${services_path}/screenservice/sinkservice/screenregionmgr/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "screen_sink_trans_fuzzer.cpp" ] + + deps = [ + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${fwk_utils_path}:distributedhardwareutils", + "//foundation/graphic/standard/frameworks/surface:surface", + "//utils/native/base:utils", + "${services_path}/screenservice/sinkservice:distributed_screen_sink", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"ScreenSinkTransFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + "multimedia_media_standard:media_client", + ] +} +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ScreenSinkTransFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init new file mode 100644 index 00000000..6b7212c8 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init @@ -0,0 +1 @@ +FUZZ \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp new file mode 100644 index 00000000..4fd91bb2 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp @@ -0,0 +1,69 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "screen_sink_trans_fuzzer.h" + +#include +#include +#include + +#include "screenregion.h" +#include "screen_sink_trans.h" +#include "screentrans_test_utils.h" + +namespace OHOS { +namespace DistributedHardware { +void ScreenSinkTransFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::shared_ptr screenSinkTrans = std::make_shared(); + std::shared_ptr param = std::make_shared(); + uint32_t screenWidth = *(reinterpret_cast(data)); + uint32_t screenHeight = *(reinterpret_cast(data)); + uint32_t videoWidth = *(reinterpret_cast(data)); + uint32_t videoHeight = *(reinterpret_cast(data)); + param->SetScreenWidth(screenWidth); + param->SetScreenHeight(screenHeight); + param->SetVideoWidth(videoWidth); + param->SetScreenHeight(videoHeight); + std::string peerDevId(reinterpret_cast(data), size); + std::string remoteDevId(reinterpret_cast(data), size); + uint64_t screenId = *(reinterpret_cast(data)); + uint64_t displayId = *(reinterpret_cast(data)); + std::shared_ptr callBack = + std::make_shared(remoteDevId, screenId, displayId); + std::string name(reinterpret_cast(data), size); + sptr surface = Surface::CreateSurfaceAsConsumer(name); + + screenSinkTrans->SetUp(*param, *param, peerDevId); + screenSinkTrans->SetImageSurface(surface); + screenSinkTrans->Start(); + screenSinkTrans->RegisterStateCallback(callBack); + screenSinkTrans->Stop(); + screenSinkTrans->Release(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ScreenSinkTransFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.h b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.h new file mode 100644 index 00000000..10783fc0 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SCREEN_SINK_TRANS_FUZZER_H +#define SCREEN_SINK_TRANS_FUZZER_H + +#define FUZZ_PROJECT_NAME "screen_sink_trans_fuzzer" + +#endif \ No newline at end of file -- Gitee From 5cbaef4efdbcc7feae425cd1a389d2a20f3d9517 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Mon, 25 Apr 2022 15:54:40 +0800 Subject: [PATCH 2/5] add screen fuzz test Signed-off-by: qinlong0101 --- .../fuzztest/screensinktrans_fuzzer/corpus/init | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init index 6b7212c8..bc977bd9 100644 --- a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init +++ b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init @@ -1 +1,14 @@ +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file -- Gitee From cce3dcb2ad6643af3305a8a91bb783cf495609a9 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Mon, 25 Apr 2022 15:59:56 +0800 Subject: [PATCH 3/5] add screen fuzz test Signed-off-by: qinlong0101 --- .../test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn | 4 +--- .../dscreen_source_proxy_fuzzer.cpp | 3 +-- .../dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h | 5 +---- .../test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn | 3 ++- .../test/fuzztest/screensinktrans_fuzzer/BUILD.gn | 3 ++- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn index a220e7fd..18528bc1 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn @@ -46,9 +46,7 @@ ohos_fuzztest("DscreenSourceProxyFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ - "dscreen_source_proxy_fuzzer.cpp", - ] + sources = [ "dscreen_source_proxy_fuzzer.cpp" ] deps = [ "//utils/native/base:utils", diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp index b52b412e..de7e8e40 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp @@ -26,7 +26,6 @@ namespace OHOS { namespace DistributedHardware { - void DscreenSourceProxyHandlerFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size <= 0)) { @@ -72,4 +71,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::DistributedHardware::DscreenSourceProxyHandlerFuzzTest(data, size); return 0; -} +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h index 2b4e44b6..6a8a9812 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h @@ -18,7 +18,4 @@ #define FUZZ_PROJECT_NAME "dscreen_source_proxy_fuzzer" -#endif - - - +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn index 7b4b1cb2..2e7fd211 100644 --- a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn @@ -21,7 +21,8 @@ import( ohos_fuzztest("ScreenSinkProcessorFuzzTest") { module_out_path = "distributed_screen/screensinkprocessor" - fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensinkprocessor_fuzzer" + fuzz_config_file = + "${services_path}/screentransport/test/fuzztest/screensinkprocessor_fuzzer" include_dirs = [ "//third_party/json/include", diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn index 1ea6bd0a..dc7495a0 100644 --- a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn @@ -21,7 +21,8 @@ import( ohos_fuzztest("ScreenSinkTransFuzzTest") { module_out_path = "distributed_screen/screensinktrans" - fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensinktrans_fuzzer" + fuzz_config_file = + "${services_path}/screentransport/test/fuzztest/screensinktrans_fuzzer" include_dirs = [ "//third_party/json/include", -- Gitee From 2e77f50a10f8b1134f3708cf2770492d30b9509d Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Mon, 25 Apr 2022 17:05:06 +0800 Subject: [PATCH 4/5] add screen fuzz test Signed-off-by: qinlong0101 --- .../native_cpp/test/fuzztest/BUILD.gn | 23 ++++++++++ .../dscreensourceproxy_fuzzer/BUILD.gn | 44 +++++++++---------- .../dscreen_source_proxy_fuzzer.cpp | 3 +- 3 files changed, 46 insertions(+), 24 deletions(-) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn new file mode 100644 index 00000000..26f7feac --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn @@ -0,0 +1,23 @@ +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +group("fuzztest") { + testonly = true + + deps = [ + "dscreensinkhandler_fuzzer:fuzztest", + "dscreensinkproxy_fuzzer:fuzztest", + "dscreensourcehandler_fuzzer:fuzztest", + "dscreensourceproxy_fuzzer:fuzztest", + ] +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn index 18528bc1..84895153 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn @@ -21,22 +21,21 @@ import( ohos_fuzztest("DscreenSourceProxyFuzzTest") { module_out_path = "distributed_screen/dscreensourceproxy" - fuzz_config_file = - "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer" + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer" include_dirs = [ - "//utils/system/safwk/native/include", - "${fwk_common_path}/utils/include", + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", ] include_dirs += [ - "include", - "include/callback", - "${common_path}/include", - "${interfaces_path}/innerkits/native_cpp/screen_source/include", - "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", - "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", - "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", ] cflags = [ @@ -49,25 +48,26 @@ ohos_fuzztest("DscreenSourceProxyFuzzTest") { sources = [ "dscreen_source_proxy_fuzzer.cpp" ] deps = [ - "//utils/native/base:utils", - "${common_path}:distributed_screen_utils", - "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", - "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${common_path}:distributed_screen_utils", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "//utils/native/base:utils", ] defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DscreenSourceProxyFuzzTest\"", - "LOG_DOMAIN=0xD004100", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DscreenSourceProxyFuzzTest\"", + "LOG_DOMAIN=0xD004100", ] external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", ] } + ############################################################################### group("fuzztest") { testonly = true diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp index de7e8e40..1a5b970f 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp @@ -45,8 +45,7 @@ void DscreenSourceProxyHandlerFuzzTest(const uint8_t* data, size_t size) param.version = str; param.attrs = str; sptr callback = new DScreenSourceCallback(); - if (callback == nullptr) - { + if (callback == nullptr) { return; } -- Gitee From 8e38724e521a9be0fded6ae65bc97fc942b882b6 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Mon, 25 Apr 2022 17:22:32 +0800 Subject: [PATCH 5/5] add screen fuzz test Signed-off-by: qinlong0101 --- interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn | 2 +- services/screentransport/test/fuzztest/BUILD.gn | 6 +++--- .../test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn | 6 +++--- .../test/fuzztest/screensinktrans_fuzzer/BUILD.gn | 7 ++++--- .../screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn index 26f7feac..da1ed29f 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn @@ -20,4 +20,4 @@ group("fuzztest") { "dscreensourcehandler_fuzzer:fuzztest", "dscreensourceproxy_fuzzer:fuzztest", ] -} \ No newline at end of file +} diff --git a/services/screentransport/test/fuzztest/BUILD.gn b/services/screentransport/test/fuzztest/BUILD.gn index a3656fce..1f508824 100644 --- a/services/screentransport/test/fuzztest/BUILD.gn +++ b/services/screentransport/test/fuzztest/BUILD.gn @@ -16,9 +16,9 @@ group("fuzztest") { deps = [ "screendatachannel_fuzzer:fuzztest", + "screensinkprocessor_fuzzer:fuzztest", + "screensinktrans_fuzzer:fuzztest", "screensourceprocessor_fuzzer:fuzztest", "screensourcetrans_fuzzer:fuzztest", - "screensinktrans_fuzzer:fuzztest", - "screensinkprocessor_fuzzer:fuzztest" ] -} \ No newline at end of file +} diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn index 2e7fd211..4648931c 100644 --- a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn @@ -21,8 +21,7 @@ import( ohos_fuzztest("ScreenSinkProcessorFuzzTest") { module_out_path = "distributed_screen/screensinkprocessor" - fuzz_config_file = - "${services_path}/screentransport/test/fuzztest/screensinkprocessor_fuzzer" + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensinkprocessor_fuzzer" include_dirs = [ "//third_party/json/include", @@ -56,8 +55,8 @@ ohos_fuzztest("ScreenSinkProcessorFuzzTest") { sources = [ "screen_sink_processor_fuzzer.cpp" ] deps = [ - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", "${fwk_utils_path}:distributedhardwareutils", + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", "//foundation/graphic/standard/frameworks/surface:surface", "//utils/native/base:utils", ] @@ -74,6 +73,7 @@ ohos_fuzztest("ScreenSinkProcessorFuzzTest") { "LOG_DOMAIN=0xD004100", ] } + ############################################################################### group("fuzztest") { testonly = true diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn index dc7495a0..97ed2768 100644 --- a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn @@ -21,7 +21,7 @@ import( ohos_fuzztest("ScreenSinkTransFuzzTest") { module_out_path = "distributed_screen/screensinktrans" - fuzz_config_file = + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensinktrans_fuzzer" include_dirs = [ @@ -56,11 +56,11 @@ ohos_fuzztest("ScreenSinkTransFuzzTest") { sources = [ "screen_sink_trans_fuzzer.cpp" ] deps = [ - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", "${fwk_utils_path}:distributedhardwareutils", + "${services_path}/screenservice/sinkservice:distributed_screen_sink", + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", "//foundation/graphic/standard/frameworks/surface:surface", "//utils/native/base:utils", - "${services_path}/screenservice/sinkservice:distributed_screen_sink", ] defines = [ @@ -75,6 +75,7 @@ ohos_fuzztest("ScreenSinkTransFuzzTest") { "multimedia_media_standard:media_client", ] } + ############################################################################### group("fuzztest") { testonly = true diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp index 4fd91bb2..4c7a4717 100644 --- a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp +++ b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp @@ -45,7 +45,7 @@ void ScreenSinkTransFuzzTest(const uint8_t* data, size_t size) std::string remoteDevId(reinterpret_cast(data), size); uint64_t screenId = *(reinterpret_cast(data)); uint64_t displayId = *(reinterpret_cast(data)); - std::shared_ptr callBack = + std::shared_ptr callBack = std::make_shared(remoteDevId, screenId, displayId); std::string name(reinterpret_cast(data), size); sptr surface = Surface::CreateSurfaceAsConsumer(name); -- Gitee