diff --git a/0001-notification-eventhandler.patch b/0001-notification-eventhandler.patch new file mode 100644 index 0000000000000000000000000000000000000000..758bc75d3ae9ff37a7da58961387ada8752ab47a --- /dev/null +++ b/0001-notification-eventhandler.patch @@ -0,0 +1,263 @@ +diff --git a/frameworks/eventhandler/BUILD.gn b/frameworks/eventhandler/BUILD.gn +index ceed950..7342337 100644 +--- a/frameworks/eventhandler/BUILD.gn ++++ b/frameworks/eventhandler/BUILD.gn +@@ -37,7 +37,7 @@ ohos_shared_library("libeventhandler") { + public_configs = [ ":public_libeventhandler_config" ] + + external_deps = [ +- "hitrace_native:libhitracechain", ++ # "hitrace_native:libhitracechain", + "hiviewdfx_hilog_native:libhilog", + ] + +diff --git a/frameworks/eventhandler/include/event_handler_utils.h b/frameworks/eventhandler/include/event_handler_utils.h +index 72fbdac..37e862f 100644 +--- a/frameworks/eventhandler/include/event_handler_utils.h ++++ b/frameworks/eventhandler/include/event_handler_utils.h +@@ -22,7 +22,7 @@ + #include + + #include "hilog/log.h" +-#include "hitrace/trace.h" ++// #include "hitrace/trace.h" + #include "inner_event.h" + + #define DEFINE_HILOG_LABEL(name) \ +@@ -66,30 +66,30 @@ static inline int32_t NanosecondsToTimeout(int64_t nanoseconds) + return (milliseconds > INT32_MAX) ? INT32_MAX : static_cast(milliseconds); + } + +-using HiTraceChain = OHOS::HiviewDFX::HiTraceChain; ++// using HiTraceChain = OHOS::HiviewDFX::HiTraceChain; + + static inline bool AllowHiTraceOutPut(const std::shared_ptr& traceId, bool isSyncEvent) + { +- if ((!traceId) || (!traceId->IsValid())) { +- return false; +- } +- if ((!isSyncEvent) && (!traceId->IsFlagEnabled(HITRACE_FLAG_INCLUDE_ASYNC))) { +- return false; +- } ++ // if ((!traceId) || (!traceId->IsValid())) { ++ // return false; ++ // } ++ // if ((!isSyncEvent) && (!traceId->IsFlagEnabled(HITRACE_FLAG_INCLUDE_ASYNC))) { ++ // return false; ++ // } + return true; + } + +-static inline void HiTracePointerOutPut(const std::shared_ptr& spanId, +- const InnerEvent::Pointer& event, const char* action, HiTraceTracepointType type) +-{ +- if (!event->HasTask()) { +- HiTraceChain::Tracepoint(type, *spanId, "%s event, event id: %d", action, event->GetInnerEventId()); +- } else if (!event->GetTaskName().empty()) { +- HiTraceChain::Tracepoint(type, *spanId, "%s task with name, name: %s", action, event->GetTaskName().c_str()); +- } else { +- HiTraceChain::Tracepoint(type, *spanId, "%s UnNamed Task", action); +- } +-} ++// static inline void HiTracePointerOutPut(const std::shared_ptr& spanId, ++// const InnerEvent::Pointer& event, const char* action, HiTraceTracepointType type) ++// { ++// if (!event->HasTask()) { ++// HiTraceChain::Tracepoint(type, *spanId, "%s event, event id: %d", action, event->GetInnerEventId()); ++// } else if (!event->GetTaskName().empty()) { ++// HiTraceChain::Tracepoint(type, *spanId, "%s task with name, name: %s", action, event->GetTaskName().c_str()); ++// } else { ++// HiTraceChain::Tracepoint(type, *spanId, "%s UnNamed Task", action); ++// } ++// } + + static inline void GetLastErr(char *errmsg, size_t size = MAX_ERRORMSG_LEN) + { +diff --git a/frameworks/eventhandler/src/event_handler.cpp b/frameworks/eventhandler/src/event_handler.cpp +index ab6e876..8477424 100644 +--- a/frameworks/eventhandler/src/event_handler.cpp ++++ b/frameworks/eventhandler/src/event_handler.cpp +@@ -74,11 +74,11 @@ bool EventHandler::SendEvent(InnerEvent::Pointer &event, int64_t delayTime, Prio + + event->SetOwner(shared_from_this()); + // get traceId from event, if HiTraceChain::begin has been called, would get a valid trace id. +- auto traceId = event->GetOrCreateTraceId(); ++ // auto traceId = event->GetOrCreateTraceId(); + // if traceId is valid, out put trace information +- if (AllowHiTraceOutPut(traceId, event->HasWaiter())) { +- HiTracePointerOutPut(traceId, event, "Send", HiTraceTracepointType::HITRACE_TP_CS); +- } ++ // if (AllowHiTraceOutPut(traceId, event->HasWaiter())) { ++ // HiTracePointerOutPut(traceId, event, "Send", HiTraceTracepointType::HITRACE_TP_CS); ++ // } + + eventRunner_->GetEventQueue()->Insert(event, priority); + return true; +@@ -117,7 +117,7 @@ bool EventHandler::SendSyncEvent(InnerEvent::Pointer &event, Priority priority) + } + + // get traceId from event, if HiTraceChain::begin has been called, would get a valid trace id. +- auto spanId = event->GetOrCreateTraceId(); ++ // auto spanId = event->GetOrCreateTraceId(); + + // Create waiter, used to block. + auto waiter = event->CreateWaiter(); +@@ -128,9 +128,9 @@ bool EventHandler::SendSyncEvent(InnerEvent::Pointer &event, Priority priority) + // Wait until event is processed(recycled). + waiter->Wait(); + +- if ((spanId) && (spanId->IsValid())) { +- HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_CR, *spanId, "event is processed"); +- } ++ // if ((spanId) && (spanId->IsValid())) { ++ // HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_CR, *spanId, "event is processed"); ++ // } + + return true; + } +@@ -305,13 +305,13 @@ void EventHandler::DistributeEvent(const InnerEvent::Pointer &event) + + currentEventHandler = shared_from_this(); + +- auto spanId = event->GetTraceId(); +- auto traceId = HiTraceChain::GetId(); +- bool allowTraceOutPut = AllowHiTraceOutPut(spanId, event->HasWaiter()); +- if (allowTraceOutPut) { +- HiTraceChain::SetId(*spanId); +- HiTracePointerOutPut(spanId, event, "Receive", HiTraceTracepointType::HITRACE_TP_SR); +- } ++ // auto spanId = event->GetTraceId(); ++ // auto traceId = HiTraceChain::GetId(); ++ // bool allowTraceOutPut = AllowHiTraceOutPut(spanId, event->HasWaiter()); ++ // if (allowTraceOutPut) { ++ // HiTraceChain::SetId(*spanId); ++ // HiTracePointerOutPut(spanId, event, "Receive", HiTraceTracepointType::HITRACE_TP_SR); ++ // } + + InnerEvent::TimePoint nowStart = InnerEvent::Clock::now(); + DeliveryTimeAction(event, nowStart); +@@ -326,13 +326,13 @@ void EventHandler::DistributeEvent(const InnerEvent::Pointer &event) + + DistributeTimeAction(event, nowStart); + +- if (allowTraceOutPut) { +- HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_SS, *spanId, "Event Distribute over"); +- HiTraceChain::ClearId(); +- if (traceId.IsValid()) { +- HiTraceChain::SetId(traceId); +- } +- } ++ // if (allowTraceOutPut) { ++ // HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_SS, *spanId, "Event Distribute over"); ++ // HiTraceChain::ClearId(); ++ // if (traceId.IsValid()) { ++ // HiTraceChain::SetId(traceId); ++ // } ++ // } + } + + void EventHandler::Dump(Dumper &dumper) +diff --git a/frameworks/eventhandler/src/inner_event.cpp b/frameworks/eventhandler/src/inner_event.cpp +index 654b44e..90e0c49 100644 +--- a/frameworks/eventhandler/src/inner_event.cpp ++++ b/frameworks/eventhandler/src/inner_event.cpp +@@ -209,9 +209,9 @@ void InnerEvent::ClearEvent() + } + } + +- if (hiTraceId_) { +- hiTraceId_.reset(); +- } ++ // if (hiTraceId_) { ++ // hiTraceId_.reset(); ++ // } + + // Clear owner + owner_.reset(); +@@ -233,25 +233,25 @@ bool InnerEvent::HasWaiter() const + return (waiter_ != nullptr); + } + +-const std::shared_ptr InnerEvent::GetOrCreateTraceId() +-{ +- if (hiTraceId_) { +- return hiTraceId_; +- } +- +- auto traceId = HiTraceChain::GetId(); +- if (!traceId.IsValid()) { +- return nullptr; +- } +- +- hiTraceId_ = std::make_shared(HiTraceChain::CreateSpan()); +- return hiTraceId_; +-} +- +-const std::shared_ptr InnerEvent::GetTraceId() +-{ +- return hiTraceId_; +-} ++// const std::shared_ptr InnerEvent::GetOrCreateTraceId() ++// { ++ // if (hiTraceId_) { ++ // return hiTraceId_; ++ // } ++ ++ // auto traceId = HiTraceChain::GetId(); ++ // if (!traceId.IsValid()) { ++ // return nullptr; ++ // } ++ ++ // hiTraceId_ = std::make_shared(HiTraceChain::CreateSpan()); ++ // return hiTraceId_; ++// } ++ ++// const std::shared_ptr InnerEvent::GetTraceId() ++// { ++// // return hiTraceId_; ++// } + + std::string InnerEvent::Dump() + { +diff --git a/interfaces/inner_api/event_queue.h b/interfaces/inner_api/event_queue.h +index 1b4d82c..e98500d 100644 +--- a/interfaces/inner_api/event_queue.h ++++ b/interfaces/inner_api/event_queue.h +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + + #include "inner_event.h" + #include "event_handler_errors.h" +diff --git a/interfaces/inner_api/inner_event.h b/interfaces/inner_api/inner_event.h +index b8fb32c..1bedc46 100644 +--- a/interfaces/inner_api/inner_event.h ++++ b/interfaces/inner_api/inner_event.h +@@ -437,14 +437,14 @@ private: + * + * @return return hiTrace Id. + */ +- const std::shared_ptr GetOrCreateTraceId(); ++ // const std::shared_ptr GetOrCreateTraceId(); + + /** + * return trace id. + * + * @return return hiTrace Id. + */ +- const std::shared_ptr GetTraceId(); ++ // const std::shared_ptr GetTraceId(); + + /* + * Calculate the type id for different smart pointers. +@@ -522,7 +522,7 @@ private: + std::shared_ptr waiter_; + + // use to store hitrace Id +- std::shared_ptr hiTraceId_; ++ // std::shared_ptr hiTraceId_; + }; + } // namespace AppExecFwk + } // namespace OHOS diff --git a/eventhandler.BUILD.gn b/eventhandler.BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1b7662cf302c0e9cbbeccb2cc9a1477957f9f3d5 --- /dev/null +++ b/eventhandler.BUILD.gn @@ -0,0 +1,18 @@ +import("//build/ohos.gni") + +config("libeventhandler_config") { + include_dirs = [ "/usr/include/eventhandler" ] + libs = ["eventhandler.z"] +} +group("libeventhandler") { + public_configs = [ ":libeventhandler_config" ] +} + +config("eventhandler_native_config") { + include_dirs = [ "/usr/include/eventhandler" ] + libs = ["eventhandler_native.z"] +} +group("eventhandler_native") { + public_configs = [ ":eventhandler_native_config" ] +} + diff --git a/eventhandler.bundle.json b/eventhandler.bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..b2b8d894172d0e196c2ebaa0bf2b296a0531c548 --- /dev/null +++ b/eventhandler.bundle.json @@ -0,0 +1,74 @@ +{ + "name": "@ohos/eventhandler", + "description": "事件处理服务", + "version": "3.1", + "license": "Apache 2.0", + "segment": { + "destPath": "base/notification/eventhandler/frameworks/eventhandler" + }, + "component": { + "name": "eventhandler", + "subsystem": "notification", + "syscap": [ + "SystemCapability.Notification.Emitter" + ], + "features": [], + "adapted_system_type": [ + "standard" + ], + "rom": "500KB", + "ram": "1000KB", + "deps": { + "components": [ + "hitrace_native", + "hiviewdfx_hilog_native", + "hichecker_native" + ], + "third_party": [] + }, + "build": { + "group_type": { + "base_group": [ + + ], + "fwk_group": [ + ], + "service_group": [ + + ] + }, + "inner_kits": [ + { + "header": { + "header_base": "//base/notification/eventhandler/libeventhandler", + "header_files": [ + "event_handler_errors.h", + "event_handler.h", + "event_queue.h", + "event_runner.h", + "inner_event.h", + "file_descriptor_listener.h", + "native_implement_eventhandler.h" + ] + }, + "name": "//base/notification/eventhandler:libeventhandler" + }, + { + "header": { + "header_base": "//base/notification/eventhandler:eventhandler_native", + "header_files": [ + "native_interface_eventhandler.h" + ] + }, + "name": "//base/notification/eventhandler:eventhandler_native" + } + ], + "test": [ + "//base/notification/eventhandler/frameworks/eventhandler/test:unittest", + "//base/notification/eventhandler/frameworks/test/moduletest:moduletest", + "//base/notification/eventhandler/test/fuzztest:fuzztest", + "//base/notification/eventhandler/test/systemtest:systemtest" + ] + } + } +} diff --git a/notification_eventhandler-OpenHarmony-v3.2-Release.tar.gz b/notification_eventhandler-OpenHarmony-v3.2-Release.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..8547a9c472107349132368793b9e91f61e93156a Binary files /dev/null and b/notification_eventhandler-OpenHarmony-v3.2-Release.tar.gz differ diff --git a/notification_eventhandler.spec b/notification_eventhandler.spec new file mode 100644 index 0000000000000000000000000000000000000000..d4816a0026e8d1661c05e471fe8dc35500bdb3b1 --- /dev/null +++ b/notification_eventhandler.spec @@ -0,0 +1,118 @@ +# 不输出debug信息,不产生debug包 +%define debug_package %{nil} +# 定义openHarmony软件包的版本变量,所有包应该都是OpenHarmony-v3.2-Release +%global oh_version OpenHarmony-v3.2-Release +# 定义下编译根目录变量,此处用/root/rpmbuild/BUILD/distributed_build作为编译根目录 +%global build_opt /opt/distributed-middleware-build +%global bundle_dir %{build_opt}/openeuler/compiler_gn/base/notification/eventhandler +%global eventhandler_path %{_builddir}/base/notification + +# rpm包名称 +Name: notification_eventhandler +# rpm包版本号 +Version: 1.0.0 +# rpm包Release号,每次修改需要+1,changelog同步修改 +Release: 1 +# rpm简介 +Summary: C++ common basic library for distributed module construction and operation +# License openHarmony的应该都是Apache License 2.0 + +License: Apache License 2.0 +# 软件包上游社区 +Url: https://gitee.com/openharmony/notification_eventhandler +# tar包的下载地址,由于gitee下载路径是不带软件包名的,会导致和name不匹配, +# 所以此处在后面用注释方式修改spec识别的tar包名称,属于取巧,但无可奈何。 +Source1: https://gitee.com/openharmony/notification_eventhandler/repository/archive/%{oh_version}.tar.gz #/%{name}-%{oh_version}.tar.gz +Source2: eventhandler.bundle.json +Source3: eventhandler.BUILD.gn +# 补丁定义 +Patch0001: 0001-notification-eventhandler.patch + + +# 编译依赖,提交代码时需要分析依赖层级,从底往上提交代码。 +BuildRequires: distributed-build, hilog, commonlibrary_c_utils +BuildRequires: python3-jinja2 python3-pyyaml +BuildRequires: libatomic libicu-devel libxml2-devel openssl-devel + +Requires: hilog +# 软件包的详细描述 +%description +Provide some commonly used C++ development tool classes for standard systems, This repository is compatible with compilation on the OpenEuler operating system +# 软件包编译前的准备阶段 + +%prep +# 解压tar包到commonlibrary_c_utils-OpenHarmony-v3.2-Release路径下 +rm -rf %{_builddir}/* +# build directory +cp -rf %{build_opt} %{_builddir}/build +[ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh +[ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn +[ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py +cp -r %{_builddir}/build/openeuler/vendor %{_builddir}/ +cp -r %{_builddir}/build/openeuler/compiler_gn/third_party %{_builddir}/ + +# 统一用setup,不用autosetup,distributed-build除外 +mkdir -p %{eventhandler_path} +%setup -q -D -T -a 1 -c -n %{eventhandler_path} +mv %{name}-%{oh_version} %{eventhandler_path}/eventhandler +# patch命令统一使用-P来指定第几个patch +%patch -P1 -p1 -d %{eventhandler_path}/eventhandler + +# 拷贝依赖的组件的gn文件 +mkdir -p %{_builddir}/base/hiviewdfx +mkdir -p %{_builddir}/commonlibrary + +cp -rf %{_builddir}/build/openeuler/compiler_gn/base/hiviewdfx/hilog %{_builddir}/base/hiviewdfx +cp -rf %{_builddir}/build/openeuler/compiler_gn/commonlibrary/c_utils %{_builddir}/commonlibrary + +# 编译阶段 +%build +rm -rf %{_builddir}/out +%ifarch x86_64 +bash %{_builddir}/build.sh --product-name openeuler --target-cpu x86_64 +%endif +%ifarch aarch64 +bash %{_builddir}/build.sh --product-name openeuler --target-cpu arm64 +%endif + +# 安装阶段 +%install +install -d -m 0755 %{buildroot}/%{_includedir}/eventhandler +install -d -m 0755 %{buildroot}/%{bundle_dir}/ +# 建so文件目录 /usr/lib64 +install -d -m 0755 %{buildroot}/%{_libdir} + +# innerkits/linux-arm64/eventhandler +%ifarch aarch64 +%define module_out_path out/openeuler/linux_clang_arm64 +%endif +%ifarch x86_64 +%define module_out_path out/openeuler/linux_clang_x86_64 +%endif + +#copy shared library files +%define so_out_path %{module_out_path}/notification/eventhandler +install -m 0755 %{_builddir}/%{so_out_path}/libeventhandler_native.z.so %{buildroot}/%{_libdir} +install -m 0755 %{_builddir}/%{so_out_path}/libeventhandler.z.so %{buildroot}/%{_libdir} + +# %define sdk_out_path %{module_out_path}/eventhandler +# cp -rf %{_builddir}/${sdk_out_path}/* %{buildroot}/%{bundle_dir}/ +cp -rf %{SOURCE2} %{buildroot}/%{bundle_dir}/bundle.json + +# 到源码路径下拷贝头文件及其目录到%{buildroot}/usr/include/eventhandler下,保持目录结构相同 +install -m 554 %{_builddir}/base/notification/eventhandler/interfaces/inner_api/*.h %{buildroot}/%{_includedir}/eventhandler + +#copy correct eventhandler BUILD.gn +cp -rf %{SOURCE3} %{buildroot}%{bundle_dir}/BUILD.gn + +# rpm安装后需要安装到系统中的文件,及上面说的so和头文件 +%files +%{_libdir}/*.so +%{_includedir}/eventhandler/* +%{bundle_dir}/* + +# 变更日志 +%changelog +* Thu Jun 15 2023 chrisshangguan - 1.0.0-1 +- Init and adapt to openeuler +