diff --git a/build/gn/BUILD.gn b/build/gn/BUILD.gn index aa643279a971d9396bb3d8369dbf231089097d83..13b1e84d5daa90f798b4d196df03d211debc7213 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 ab60f356ac9ddad869dac5243e77fb6b3ce1ff18..db4c5af10b4d57313c67bfe3c27158408d17bdd1 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 0000000000000000000000000000000000000000..231148d23afdf1f2cce3a5c3039027b8399e092e --- /dev/null +++ b/wayland_adapter/BUILD.gn @@ -0,0 +1,36 @@ +# 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" ] + + 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 0000000000000000000000000000000000000000..0487cc6a6cd7b076615ccd24bab429d25681525a --- /dev/null +++ b/wayland_adapter/wayland_adapter_hilog.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#ifndef WAYLAND_ADAPTER_HILOG_H +#define WAYLAND_ADAPTER_HILOG_H + +#include "hilog/log.h" + +using namespace OHOS::HiviewDFX; + +namespace FT { +namespace Wayland { +static constexpr unsigned int HILOG_DOMAIN_WAYLAND = 0xD004202; + +#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 new file mode 100644 index 0000000000000000000000000000000000000000..4c35b7e58f91d51c996da9a550339907584d22a9 --- /dev/null +++ b/wayland_adapter/wayland_server.cpp @@ -0,0 +1,54 @@ +/* + * 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. + */ + +#include "wayland_server.h" + +#include +#include "wayland_adapter_hilog.h" + +namespace FT { +namespace Wayland { +namespace { + constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandServer"}; +} + +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 {} + +void WaylandServer::OnStart() +{ + LOG_INFO("OnStart"); +} + +void WaylandServer::OnStop() +{ + LOG_INFO("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 0000000000000000000000000000000000000000..5c362f9e8b641d32aa43b09f92269ff9f67faf40 --- /dev/null +++ b/wayland_adapter/wayland_server.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#ifndef WAYLAND_SERVER_H +#define WAYLAND_SERVER_H + +#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