From 8c121a86c4c6239eb2706d9d89a98c1e73ced586 Mon Sep 17 00:00:00 2001 From: abc12133 Date: Mon, 28 Aug 2023 17:23:21 +0800 Subject: [PATCH 1/6] add wayland adapter Signed-off-by: abc12133 --- build/gn/BUILD.gn | 6 +++ etc/ft.xml | 9 +++++ wayland_adapter/BUILD.gn | 44 ++++++++++++++++++++++ wayland_adapter/wayland_adapter_hilog.h | 35 +++++++++++++++++ wayland_adapter/wayland_server.cpp | 50 +++++++++++++++++++++++++ wayland_adapter/wayland_server.h | 41 ++++++++++++++++++++ 6 files changed, 185 insertions(+) create mode 100644 wayland_adapter/BUILD.gn create mode 100644 wayland_adapter/wayland_adapter_hilog.h create mode 100644 wayland_adapter/wayland_server.cpp create mode 100644 wayland_adapter/wayland_server.h diff --git a/build/gn/BUILD.gn b/build/gn/BUILD.gn index aa64327..13b1e84 100644 --- a/build/gn/BUILD.gn +++ b/build/gn/BUILD.gn @@ -27,6 +27,12 @@ group("ft_window_manager") { ] } +group("ft_wayland_adapter") { + deps = [ + "//wayland_adapter:libwayland_adapter", + ] +} + group("samples") { deps = [ "//samples:clock", diff --git a/etc/ft.xml b/etc/ft.xml index ab60f35..db4c5af 100644 --- a/etc/ft.xml +++ b/etc/ft.xml @@ -19,6 +19,7 @@ /usr/lib64/librender_service.so /usr/lib64/libmmi-server.so /usr/lib64/libdms.so + /usr/lib64/libwayland_adapter.so /usr/lib64/libwms.so @@ -38,6 +39,14 @@ 1 + + 4600 + /usr/lib64/libwayland_adapter.so + true + false + 1 + + 4607 /usr/lib64/libdms.so diff --git a/wayland_adapter/BUILD.gn b/wayland_adapter/BUILD.gn new file mode 100644 index 0000000..c9685d6 --- /dev/null +++ b/wayland_adapter/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2023 Huawei Technologies 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. + +import("//build/gn/fangtian.gni") +import("//config.gni") + +config("libwayland_adapter_config") { + visibility = [ ":*" ] + + cflags = [ "-Wno-c++11-narrowing" ] + + include_dirs = [ + ".", + ] +} + +ft_shared_library("libwayland_adapter") { + defines = ft_defines + + sources = [ + "wayland_server.cpp", + ] + + configs = [ + ":libwayland_adapter_config", + ] + + libs = [ "xml2" ] + + deps = [ + "//build/gn/configs/system_libs:hilog", + "//build/gn/configs/system_libs:safwk", + ] +} diff --git a/wayland_adapter/wayland_adapter_hilog.h b/wayland_adapter/wayland_adapter_hilog.h new file mode 100644 index 0000000..beb59f7 --- /dev/null +++ b/wayland_adapter/wayland_adapter_hilog.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 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 WAYLAND_ADAPTER_HILOG_H +#define WAYLAND_ADAPTER_HILOG_H + +#include "hilog/log.h" + +using namespace OHOS::HiviewDFX; + +namespace FT { +namespace Wayland { +constexpr HiLogLabel LABEL = { LOG_CORE, 0xD004202, "WaylandAdapter" }; + +#define LOG_FATAL(format, ...) HiLog::Fatal(LABEL, format, ##__VA_ARGS__) +#define LOG_ERROR(format, ...) HiLog::Error(LABEL, format, ##__VA_ARGS__) +#define LOG_WARN(format, ...) HiLog::Warn(LABEL, format, ##__VA_ARGS__) +#define LOG_INFO(format, ...) HiLog::Info(LABEL, format, ##__VA_ARGS__) +#define LOG_DEBUG(format, ...) HiLog::Debug(LABEL, format, ##__VA_ARGS__) +#define LOG_TRACE(format, ...) HiLog::Trace(LABEL, format, ##__VA_ARGS__) +} // namespace Wayland +} // namespace FT +#endif // WAYLAND_ADAPTER_HILOG_H diff --git a/wayland_adapter/wayland_server.cpp b/wayland_adapter/wayland_server.cpp new file mode 100644 index 0000000..cb3d131 --- /dev/null +++ b/wayland_adapter/wayland_server.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 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 "wayland_server.h" + +#include +#include "wayland_adapter_hilog.h" + +namespace FT { +namespace Wayland { +const bool REGISTER_RESULT = + OHOS::SystemAbility::MakeAndRegisterAbility(new WaylandServer()); + +WaylandServer::WaylandServer() : OHOS::SystemAbility(OHOS::WINDOW_MANAGER_ID, true) {} + +WaylandServer::~WaylandServer() noexcept {} + +void WaylandServer::OnStart() +{ + LOG_INFO("WaylandServer::OnStart"); +} + +void WaylandServer::OnStop() +{ + LOG_INFO("WaylandServer::OnStop"); +} + +void WaylandServer::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) +{ + LOG_INFO("systemAbilityId: %{public}d, start", systemAbilityId); +} + +std::string WaylandServer::GetClassName() +{ + return "WaylandServer"; +} +} // namespace Wayland +} // namespace FT diff --git a/wayland_adapter/wayland_server.h b/wayland_adapter/wayland_server.h new file mode 100644 index 0000000..56fa4dc --- /dev/null +++ b/wayland_adapter/wayland_server.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 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 WAYLAND_SERVER_H +#define WAYLAND_SERVER_H + +#include +#include +#include + +namespace FT { +namespace Wayland { +class WaylandServer : public OHOS::SystemAbility { +public: + WaylandServer(); + ~WaylandServer() noexcept; + + WaylandServer(const WaylandServer&) = delete; + WaylandServer& operator=(const WaylandServer&) = delete; + + // sa_main implementation + void OnStart() override; + void OnStop() override; + void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; + std::string GetClassName() override; +}; +} // namespace Wayland +} // namespace FT +#endif // WAYLAND_SERVER_H -- Gitee From dfd9cea528bc52a92d4f3abebf9a4469623e3b3f Mon Sep 17 00:00:00 2001 From: abc12133 Date: Mon, 28 Aug 2023 17:23:57 +0800 Subject: [PATCH 2/6] gn format Signed-off-by: abc12133 --- wayland_adapter/BUILD.gn | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/wayland_adapter/BUILD.gn b/wayland_adapter/BUILD.gn index c9685d6..231148d 100644 --- a/wayland_adapter/BUILD.gn +++ b/wayland_adapter/BUILD.gn @@ -19,23 +19,15 @@ config("libwayland_adapter_config") { cflags = [ "-Wno-c++11-narrowing" ] - include_dirs = [ - ".", - ] + include_dirs = [ "." ] } ft_shared_library("libwayland_adapter") { defines = ft_defines - sources = [ - "wayland_server.cpp", - ] - - configs = [ - ":libwayland_adapter_config", - ] + sources = [ "wayland_server.cpp" ] - libs = [ "xml2" ] + configs = [ ":libwayland_adapter_config" ] deps = [ "//build/gn/configs/system_libs:hilog", -- Gitee From d54a1945804616ec2d66bc92bb014ec8ecfc5c23 Mon Sep 17 00:00:00 2001 From: abc12133 Date: Mon, 28 Aug 2023 19:03:29 +0800 Subject: [PATCH 3/6] fix Signed-off-by: abc12133 --- wayland_adapter/wayland_adapter_hilog.h | 19 ++++++++++++------- wayland_adapter/wayland_server.cpp | 11 +++++++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/wayland_adapter/wayland_adapter_hilog.h b/wayland_adapter/wayland_adapter_hilog.h index beb59f7..f1c16de 100644 --- a/wayland_adapter/wayland_adapter_hilog.h +++ b/wayland_adapter/wayland_adapter_hilog.h @@ -22,14 +22,19 @@ using namespace OHOS::HiviewDFX; namespace FT { namespace Wayland { -constexpr HiLogLabel LABEL = { LOG_CORE, 0xD004202, "WaylandAdapter" }; +static constexpr unsigned int HILOG_DOMAIN_WAYLAND = 0xD004202; -#define LOG_FATAL(format, ...) HiLog::Fatal(LABEL, format, ##__VA_ARGS__) -#define LOG_ERROR(format, ...) HiLog::Error(LABEL, format, ##__VA_ARGS__) -#define LOG_WARN(format, ...) HiLog::Warn(LABEL, format, ##__VA_ARGS__) -#define LOG_INFO(format, ...) HiLog::Info(LABEL, format, ##__VA_ARGS__) -#define LOG_DEBUG(format, ...) HiLog::Debug(LABEL, format, ##__VA_ARGS__) -#define LOG_TRACE(format, ...) HiLog::Trace(LABEL, format, ##__VA_ARGS__) +#define _W_CPRINTF(func, fmt, ...) func(LABEL, "<%{public}d>" fmt, __LINE__, ##__VA_ARGS__) +#define WLOGD(fmt, ...) _W_CPRINTF(HiLog::Debug, fmt, ##__VA_ARGS__) +#define WLOGI(fmt, ...) _W_CPRINTF(HiLog::Info, fmt, ##__VA_ARGS__) +#define WLOGW(fmt, ...) _W_CPRINTF(HiLog::Warn, fmt, ##__VA_ARGS__) +#define WLOGE(fmt, ...) _W_CPRINTF(HiLog::Error, fmt, ##__VA_ARGS__) + +#define _W_FUNC __func__ +#define LOG_DEBUG(fmt, ...) WLOGD("%{public}s: " fmt, _W_FUNC, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) WLOGI("%{public}s: " fmt, _W_FUNC, ##__VA_ARGS__) +#define LOG_WARN(fmt, ...) WLOGW("%{public}s: " fmt, _W_FUNC, ##__VA_ARGS__) +#define LOG_ERROR(fmt, ...) WLOGE("%{public}s: " fmt, _W_FUNC, ##__VA_ARGS__) } // namespace Wayland } // namespace FT #endif // WAYLAND_ADAPTER_HILOG_H diff --git a/wayland_adapter/wayland_server.cpp b/wayland_adapter/wayland_server.cpp index cb3d131..8268758 100644 --- a/wayland_adapter/wayland_server.cpp +++ b/wayland_adapter/wayland_server.cpp @@ -20,8 +20,11 @@ namespace FT { namespace Wayland { -const bool REGISTER_RESULT = - OHOS::SystemAbility::MakeAndRegisterAbility(new WaylandServer()); +namespace { + constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandServer"}; +} + +const bool REGISTER_RESULT = OHOS::SystemAbility::MakeAndRegisterAbility(new WaylandServer()); WaylandServer::WaylandServer() : OHOS::SystemAbility(OHOS::WINDOW_MANAGER_ID, true) {} @@ -29,12 +32,12 @@ WaylandServer::~WaylandServer() noexcept {} void WaylandServer::OnStart() { - LOG_INFO("WaylandServer::OnStart"); + LOG_INFO("OnStart"); } void WaylandServer::OnStop() { - LOG_INFO("WaylandServer::OnStop"); + LOG_INFO("OnStop"); } void WaylandServer::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) -- Gitee From f00b0c280049245716275978611568ad4160e998 Mon Sep 17 00:00:00 2001 From: abc12133 Date: Mon, 28 Aug 2023 19:05:01 +0800 Subject: [PATCH 4/6] remove unused header Signed-off-by: abc12133 --- wayland_adapter/wayland_server.h | 1 - 1 file changed, 1 deletion(-) diff --git a/wayland_adapter/wayland_server.h b/wayland_adapter/wayland_server.h index 56fa4dc..8c65521 100644 --- a/wayland_adapter/wayland_server.h +++ b/wayland_adapter/wayland_server.h @@ -17,7 +17,6 @@ #define WAYLAND_SERVER_H #include -#include #include namespace FT { -- Gitee From 72ac5d288f7097c105d1678aef18c8edb6b22bd5 Mon Sep 17 00:00:00 2001 From: abc12133 Date: Mon, 28 Aug 2023 20:17:25 +0800 Subject: [PATCH 5/6] add comment Signed-off-by: abc12133 --- wayland_adapter/wayland_server.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wayland_adapter/wayland_server.cpp b/wayland_adapter/wayland_server.cpp index 8268758..a726e01 100644 --- a/wayland_adapter/wayland_server.cpp +++ b/wayland_adapter/wayland_server.cpp @@ -26,6 +26,7 @@ namespace { const bool REGISTER_RESULT = OHOS::SystemAbility::MakeAndRegisterAbility(new WaylandServer()); +// TODO: replace WINDOW_MANAGER_ID with WAYLAND_ADAPTER_ID WaylandServer::WaylandServer() : OHOS::SystemAbility(OHOS::WINDOW_MANAGER_ID, true) {} WaylandServer::~WaylandServer() noexcept {} -- Gitee From b0d009a8c91a0ae75022f0271c087852554fdb34 Mon Sep 17 00:00:00 2001 From: abc12133 Date: Tue, 29 Aug 2023 09:16:13 +0800 Subject: [PATCH 6/6] fix comment Signed-off-by: abc12133 --- wayland_adapter/wayland_adapter_hilog.h | 2 +- wayland_adapter/wayland_server.cpp | 2 +- wayland_adapter/wayland_server.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wayland_adapter/wayland_adapter_hilog.h b/wayland_adapter/wayland_adapter_hilog.h index f1c16de..0487cc6 100644 --- a/wayland_adapter/wayland_adapter_hilog.h +++ b/wayland_adapter/wayland_adapter_hilog.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023 Huawei Technologies 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 diff --git a/wayland_adapter/wayland_server.cpp b/wayland_adapter/wayland_server.cpp index a726e01..4c35b7e 100644 --- a/wayland_adapter/wayland_server.cpp +++ b/wayland_adapter/wayland_server.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023 Huawei Technologies 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 diff --git a/wayland_adapter/wayland_server.h b/wayland_adapter/wayland_server.h index 8c65521..5c362f9 100644 --- a/wayland_adapter/wayland_server.h +++ b/wayland_adapter/wayland_server.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023 Huawei Technologies 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 -- Gitee