1 Star 0 Fork 12

chrisshangguan/distributed-build

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0017-add-eventhandler-config_policy-c_utils.patch 98.37 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565
diff --git a/commonlibrary/c_utils/LICENSE b/commonlibrary/c_utils/LICENSE
new file mode 100644
index 0000000..4947287
--- /dev/null
+++ b/commonlibrary/c_utils/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/commonlibrary/c_utils/README.md b/commonlibrary/c_utils/README.md
new file mode 100644
index 0000000..b291124
--- /dev/null
+++ b/commonlibrary/c_utils/README.md
@@ -0,0 +1,157 @@
+# commonlibrary/c_utils<a name="EN-US_TOPIC_0000001148676553"></a>
+
+## Introduction<a name="section11660541593"></a>
+
+The **commonlibrary/c_utils** repository provides the following commonly used C++ utility classes for standard system:
+
+- Enhanced APIs for operations related to files, paths, and strings
+- APIs related to the read-write lock, semaphore, timer, thread, and thread pool
+- APIs related to the security data container and data serialization
+- Error codes for each subsystem
+
+## Directory Structure<a name="section17271017133915"></a>
+
+```
+commonlibrary/c_utils
+└─ base
+ ├── include # Header files of APIs open to other subsystems
+ ├── src # Source files
+ └── test # Test code
+```
+## Condition
+Suitable for standard system.
+
+## Build
+### Build Component
+```
+./build.sh --product-name rk3568 --build-target c_utils
+```
+
+### Build Shared Library
+```
+./build.sh --product-name rk3568 --build-target commonlibrary/c_utils/base:utils
+```
+
+### Build Static Library
+```
+./build.sh --product-name rk3568 --build-target commonlibrary/c_utils/base:utilsbase
+```
+## Coding Directions
+### ashmem
+```
+sptr<Ashmem> ashmem = Ashmem::CreateAshmem(MEMORY_NAME.c_str(), MEMORY_SIZE);
+if (ashmem != nullptr) {
+ bool ret = ashmem->MapAshmem(PROT_READ | PROT_WRITE);
+}
+
+...
+
+// Do not forget to unmap & close ashmem at the end
+ashmem->UnmapAshmem();
+ashmem->CloseAshmem();
+```
+
+### parcel
+```
+// Write data into parcel in some order at writing port
+struct TestData {
+ bool booltest;
+ int8_t int8test;
+ int16_t int16test;
+ int32_t int32test;
+ uint8_t uint8test;
+ uint16_t uint16test;
+ uint32_t uint32test;
+};
+
+...
+
+Parcel parcel(nullptr);
+struct TestData data = { true, -0x34, 0x5634, -0x12345678, 0x34, 0x5634, 0x12345678 };
+bool result = false;
+
+result = parcel.WriteBool(data.booltest);
+if (!result) {
+ // Deal with writing failure
+}
+
+result = parcel.WriteInt8(data.int8test);
+if (!result) {
+ // Deal with writing failure
+}
+
+result = parcel.WriteInt16(data.int16test);
+if (!result) {
+ // Deal with writing failure
+}
+
+result = parcel.WriteInt32(data.int32test);
+if (!result) {
+ // Deal with writing failure
+}
+
+result = parcel.WriteUint8(data.uint8test);
+if (!result) {
+ // Deal with writing failure
+}
+
+result = parcel.WriteUint16(data.uint16test);
+if (!result) {
+ // Deal with writing failure
+}
+
+result = parcel.WriteUint32(data.uint32test);
+if (!result) {
+ // Deal with writing failure
+}
+```
+```
+// Read data with the order writing in at reading port
+bool readbool = parcel.ReadBool();
+
+int8_t readint8 = parcel.ReadInt8();
+
+int16_t readint16 = parcel.ReadInt16();
+
+int32_t readint32 = parcel.ReadInt32();
+
+uint8_t readuint8 = parcel.ReadUint8();
+
+uint16_t readuint16 = parcel.ReadUint16();
+
+uint32_t readuint32 = parcel.ReadUint32();
+```
+### refbase
+```
+class TestRefBase : public RefBase {
+...
+};
+...
+sptr<TestRefBase> test(new TestRefBase());
+...
+```
+### timer
+```
+void TimeOutCallback()
+{
+ ...
+}
+...
+Utils::Timer timer("test_timer");
+uint32_t ret = timer.Setup();
+timer.Register(TimeOutCallback, 1, true);
+std::this_thread::sleep_for(std::chrono::milliseconds(15));
+timer.Shutdown();
+```
+
+## Changelog
+**2022/10/10**
+1. Move this repository from utils/native to commonlibrary/c_utils.
+2. Switch component name from utils_base to c_utils.
+3. Securec is not in this repository any more. Please use [third_party_bounds_checking_function](https://gitee.com/openharmony/third_party_bounds_checking_function).
+## Repositories Involved<a name="section1249817110914"></a>
+
+**[commonlibrary\_c\_utils](https://gitee.com/openharmony/commonlibrary_c_utils)**
+
+[commonlibrary\_utils\_lite](https://gitee.com/openharmony/commonlibrary_utils_lite)
+
diff --git a/commonlibrary/c_utils/README_zh.md b/commonlibrary/c_utils/README_zh.md
new file mode 100644
index 0000000..02a6cdb
--- /dev/null
+++ b/commonlibrary/c_utils/README_zh.md
@@ -0,0 +1,159 @@
+# C++公共基础库<a name="ZH-CN_TOPIC_0000001148676553"></a>
+
+
+## 简介<a name="section11660541593"></a>
+
+C++公共基础类库为标准系统提供了一些常用的C++开发工具类,包括:
+
+- 文件、路径、字符串相关操作的能力增强接口
+- 读写锁、信号量、定时器、线程增强及线程池等接口
+- 安全数据容器、数据序列化等接口
+- 各子系统的错误码相关定义
+
+## 目录<a name="section17271017133915"></a>
+
+```
+commonlibrary/c_utils
+└─ base
+ ├── include # 对各子系统开放的接口头文件
+ ├── src # 源文件
+ └── test # 测试代码
+```
+
+## 约束
+
+适用于标准系统。
+## 编译构建
+### 编译部件
+```
+./build.sh --product-name rk3568 --build-target c_utils
+```
+
+### 编译动态库
+```
+./build.sh --product-name rk3568 --build-target commonlibrary/c_utils/base:utils
+```
+
+### 编译静态库
+```
+./build.sh --product-name rk3568 --build-target commonlibrary/c_utils/base:utilsbase
+```
+## 使用说明
+### ashmem
+```
+sptr<Ashmem> ashmem = Ashmem::CreateAshmem(MEMORY_NAME.c_str(), MEMORY_SIZE);
+if (ashmem != nullptr) {
+ bool ret = ashmem->MapAshmem(PROT_READ | PROT_WRITE);
+}
+
+...
+
+// 当使用结束时不要忘记解映射和关闭ashmem
+ashmem->UnmapAshmem();
+ashmem->CloseAshmem();
+```
+
+### parcel
+```
+// 写入端以某种顺序写入数据
+struct TestData {
+ bool booltest;
+ int8_t int8test;
+ int16_t int16test;
+ int32_t int32test;
+ uint8_t uint8test;
+ uint16_t uint16test;
+ uint32_t uint32test;
+};
+
+...
+
+Parcel parcel(nullptr);
+struct TestData data = { true, -0x34, 0x5634, -0x12345678, 0x34, 0x5634, 0x12345678 };
+bool result = false;
+
+result = parcel.WriteBool(data.booltest);
+if (!result) {
+ // 写失败处理
+}
+
+result = parcel.WriteInt8(data.int8test);
+if (!result) {
+ // 写失败处理
+}
+
+result = parcel.WriteInt16(data.int16test);
+if (!result) {
+ // 写失败处理
+}
+
+result = parcel.WriteInt32(data.int32test);
+if (!result) {
+ // 写失败处理
+}
+
+result = parcel.WriteUint8(data.uint8test);
+if (!result) {
+ // 写失败处理
+}
+
+result = parcel.WriteUint16(data.uint16test);
+if (!result) {
+ // 写失败处理
+}
+
+result = parcel.WriteUint32(data.uint32test);
+if (!result) {
+ // 写失败处理
+}
+```
+```
+// 接收端根据写入端写入顺序读取数据
+bool readbool = parcel.ReadBool();
+
+int8_t readint8 = parcel.ReadInt8();
+
+int16_t readint16 = parcel.ReadInt16();
+
+int32_t readint32 = parcel.ReadInt32();
+
+uint8_t readuint8 = parcel.ReadUint8();
+
+uint16_t readuint16 = parcel.ReadUint16();
+
+uint32_t readuint32 = parcel.ReadUint32();
+```
+### refbase
+```
+class TestRefBase : public RefBase {
+...
+};
+...
+sptr<TestRefBase> test(new TestRefBase());
+...
+```
+### timer
+```
+void TimeOutCallback()
+{
+ ...
+}
+...
+Utils::Timer timer("test_timer");
+uint32_t ret = timer.Setup();
+timer.Register(TimeOutCallback, 1, true);
+std::this_thread::sleep_for(std::chrono::milliseconds(15));
+timer.Shutdown();
+```
+
+## Changelog
+**2022/10/10**
+1. 路径变更。由utils/native移动至commonlibrary/c_utils;
+2. 部件名变更。由utils_base变更为c_utils;
+3. 不再提供安全C库能力。请使用[third_party_bounds_checking_function](https://gitee.com/openharmony/third_party_bounds_checking_function)。
+## 相关仓<a name="section1249817110914"></a>
+
+**[commonlibrary\_c\_utils](https://gitee.com/openharmony/commonlibrary_c_utils)**
+
+[commonlibrary\_utils\_lite](https://gitee.com/openharmony/commonlibrary_utils_lite)
+
diff --git a/commonlibrary/c_utils/base/BUILD.gn b/commonlibrary/c_utils/base/BUILD.gn
new file mode 100644
index 0000000..b89a67b
--- /dev/null
+++ b/commonlibrary/c_utils/base/BUILD.gn
@@ -0,0 +1,23 @@
+# Copyright (c) 2021 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.
+import("//build/ohos.gni")
+
+config("utils_all_dependent_configs") {
+ include_dirs = [ "include" ]
+ libs = ["utils.z"]
+}
+
+ohos_shared_library("utils") {
+ all_dependent_configs = [ ":utils_all_dependent_configs" ]
+}
+###############################################################################
diff --git a/commonlibrary/c_utils/base/include b/commonlibrary/c_utils/base/include
new file mode 120000
index 0000000..6ed1680
--- /dev/null
+++ b/commonlibrary/c_utils/base/include
@@ -0,0 +1 @@
+/usr/include/c_utils
\ No newline at end of file
diff --git a/commonlibrary/c_utils/bundle.json b/commonlibrary/c_utils/bundle.json
new file mode 100644
index 0000000..664ed34
--- /dev/null
+++ b/commonlibrary/c_utils/bundle.json
@@ -0,0 +1,71 @@
+{
+ "name": "@openharmony/c_utils",
+ "version": "3.1.0",
+ "description": "c_utils",
+ "publishAs": "code-segment",
+ "segment": {
+ "destPath": "commonlibrary/c_utils"
+ },
+ "scripts": {
+ "install": "DEST_PATH=${DEP_BUNDLE_BASE}/commonlibrary/c_utils/base && mkdir -p $DEST_PATH && cp -r ./* $DEST_PATH"
+ },
+ "author": {},
+ "repository": "",
+ "license": "Apache License 2.0",
+ "component": {
+ "name": "c_utils",
+ "subsystem": "commonlibrary",
+ "adapted_system_type": [ "standard" ],
+ "deps": {
+ "components": [
+ "hilog_native"
+ ],
+ "third_party": []
+ },
+ "build": {
+ "sub_component": [
+ "//commonlibrary/c_utils/base:utils"
+ ],
+ "inner_kits": [
+ {
+ "name": "//commonlibrary/c_utils/base:utils",
+ "header": {
+ "header_files": [
+ "ashmem.h",
+ "common_errors.h",
+ "common_timer_errors.h",
+ "datetime_ex.h",
+ "directory_ex.h",
+ "errors.h",
+ "file_ex.h",
+ "flat_obj.h",
+ "nocopyable.h",
+ "observer.h",
+ "parcel.h",
+ "pubdef.h",
+ "refbase.h",
+ "rwlock.h",
+ "safe_block_queue.h",
+ "safe_map.h",
+ "safe_queue.h",
+ "securec.h",
+ "securectype.h",
+ "semaphore_ex.h",
+ "singleton.h",
+ "sorted_vector.h",
+ "string_ex.h",
+ "thread_ex.h",
+ "thread_pool.h",
+ "timer.h",
+ "unique_fd.h"
+ ],
+ "header_base": "//commonlibrary/c_utils/base/include"
+ }
+ }
+ ],
+ "test": [
+ "//commonlibrary/c_utils/base/test:unittest"
+ ]
+ }
+ }
+}
diff --git a/customization/config_policy/.gitee/ISSUE_TEMPLATE.zh-CN.md b/customization/config_policy/.gitee/ISSUE_TEMPLATE.zh-CN.md
new file mode 100644
index 0000000..651e02c
--- /dev/null
+++ b/customization/config_policy/.gitee/ISSUE_TEMPLATE.zh-CN.md
@@ -0,0 +1,11 @@
+### 该问题是怎么引起的?
+
+
+
+### 重现步骤
+
+
+
+### 报错信息
+
+
diff --git a/customization/config_policy/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/customization/config_policy/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
new file mode 100644
index 0000000..86dd358
--- /dev/null
+++ b/customization/config_policy/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
@@ -0,0 +1,12 @@
+### 相关的Issue
+
+
+### 原因(目的、解决的问题等)
+
+
+### 描述(做了什么,变更了什么)
+
+
+### 测试用例(新增、改动、可能影响的功能)
+
+
diff --git a/customization/config_policy/BUILD.gn b/customization/config_policy/BUILD.gn
new file mode 100644
index 0000000..7f574fb
--- /dev/null
+++ b/customization/config_policy/BUILD.gn
@@ -0,0 +1,24 @@
+# Copyright (c) 2022-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.
+
+import("//base/customization/config_policy/config_policy.gni")
+
+group("config_policy_components") {
+ if (os_level == "standard" && support_config_policy_napi) {
+ deps = [
+ "//base/customization/config_policy/frameworks/config_policy:configpolicy_util",
+ ]
+ } else {
+ deps = [ "//base/customization/config_policy/frameworks/config_policy:configpolicy_util" ]
+ }
+}
diff --git a/customization/config_policy/LICENSE b/customization/config_policy/LICENSE
new file mode 100644
index 0000000..4947287
--- /dev/null
+++ b/customization/config_policy/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/customization/config_policy/README.md b/customization/config_policy/README.md
new file mode 100644
index 0000000..79663ff
--- /dev/null
+++ b/customization/config_policy/README.md
@@ -0,0 +1,42 @@
+# Config Policy
+
+## Introduction
+
+The config policy, namely, cust, provides APIs for each service module to obtain the configuration directories at different levels or the configuration file paths.
+
+## Directory Structure
+
+The directory structure for the config policy is as follows:
+
+```
+/base/customization/
+├── config_policy # Code repository for the config policy
+│ ├── frameworks # Core code of the config policy
+│ │ ├── config_policy # config policy
+│ │ │ └── src # Implementation code
+│ ├── interfaces # APIs of the config policy
+│ │ ├── inner_api # APIs of the config policy for internal subsystems
+│ │ └── kits # JavaScript APIs
+│ └── test # Test code
+```
+
+## Usage
+
+Call the APIs of the config policy to obtain the configuration directories at different levels or the configuration file paths.
+
+```
+#include "config_policy_utils.h"
+
+const char *testPathSuffix = "user.xml"; // Set the name of the configuration file.
+char buf[MAX_PATH_LEN] = {0};
+char *filePath = GetOneCfgFile(testPathSuffix, buf, MAX_PATH_LEN); // Obtain the path of the configuration file with the highest priority.
+```
+
+## Constraints
+
+**Programming language**: C/C++
+
+## Repositories Involved
+
+**customization\_config\_policy**
+
diff --git a/customization/config_policy/README_zh.md b/customization/config_policy/README_zh.md
new file mode 100644
index 0000000..ae7d939
--- /dev/null
+++ b/customization/config_policy/README_zh.md
@@ -0,0 +1,53 @@
+# 配置策略组件介绍
+
+## 简介
+
+配置策略组件为各业务模块提供获取各配置层级的配置目录或配置文件路径的接口。
+
+## 系统架构
+
+**图 1** 配置策略组件架构图
+
+![](figures/config_policy.png)
+
+配置策略组件架构图说明:
+
+- interfaces对外提供指定文件的最高优先级文件路径以及指定文件所有层级路径。
+- frameworks实现配置层级目录的初始化与文件路径查询。
+
+## 目录
+
+配置策略组件源代码目录结构如下所示:
+
+```
+/base/customization/
+├── config_policy # 配置策略代码仓
+│ ├── frameworks # 配置策略核心代码
+│ │ ├── config_policy # 配置策略模块
+│ │ │ └── src # 实现代码
+│ ├── interfaces # 配置策略接口
+│ │ ├── inner_api # 子系统间接口
+│ │ └── kits # 配置策略JavaScript接口
+│ └── test # 测试代码
+```
+
+## 说明
+
+调用该组件中的接口获取各配置层级的配置目录或配置文件路径。
+
+```
+#include "config_policy_utils.h"
+
+const char *testPathSuffix = "user.xml"; //设置配置文件名称
+char buf[MAX_PATH_LEN] = {0};
+char *filePath = GetOneCfgFile(testPathSuffix, buf, MAX_PATH_LEN); //获取最高优先级的配置文件路径
+```
+
+## 约束
+
+**语言限制**:C/C++语言
+
+## 相关仓
+
+**customization\_config\_policy**
+
diff --git a/customization/config_policy/bundle.json b/customization/config_policy/bundle.json
new file mode 100644
index 0000000..380e9d0
--- /dev/null
+++ b/customization/config_policy/bundle.json
@@ -0,0 +1,55 @@
+{
+ "name": "@ohos/customization_config_policy",
+ "description": "The customization framework, namely, cust, provides APIs for each service module to obtain the configuration directories at different levels or the configuration file paths.",
+ "version": "3.1",
+ "license": "Apache License 2.0",
+ "publishAs": "code-segment",
+ "segment": {
+ "destPath": "base/customization/config_policy"
+ },
+ "dirs": {},
+ "scripts": {},
+ "component": {
+ "name": "config_policy",
+ "subsystem": "customization",
+ "syscap": [ "SystemCapability.Customization.ConfigPolicy" ],
+ "features": [],
+ "adapted_system_type": [ "standard", "small" ],
+ "hisysevent_config": [
+ "//base/customization/config_policy/frameworks/dfx/hisysevent.yaml"
+ ],
+ "rom": "",
+ "ram": "",
+ "deps": {
+ "components": [
+ "common",
+ "hisysevent_native",
+ "hiviewdfx_hilog_native",
+ "napi",
+ "init"
+ ],
+ "third_party": [
+ "bounds_checking_function"
+ ]
+ },
+ "build": {
+ "sub_component": [
+ "//base/customization/config_policy:config_policy_components"
+ ],
+ "inner_kits": [
+ {
+ "header": {
+ "header_base": "//base/customization/config_policy/interfaces/inner_api/include",
+ "header_files": [
+ "config_policy_utils.h"
+ ]
+ },
+ "name": "//base/customization/config_policy/frameworks/config_policy:configpolicy_util"
+ }
+ ],
+ "test": [
+ "//base/customization/config_policy/test/unittest:ConfigPolicyUtilsTest"
+ ]
+ }
+ }
+}
diff --git a/customization/config_policy/config_policy.gni b/customization/config_policy/config_policy.gni
new file mode 100644
index 0000000..1d0388e
--- /dev/null
+++ b/customization/config_policy/config_policy.gni
@@ -0,0 +1,20 @@
+# 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.
+
+declare_args() {
+ # if fs has prefix before OH path, set it here
+ config_policy_fs_prefix = ""
+
+ # Whether support napi so
+ support_config_policy_napi = false
+}
diff --git a/customization/config_policy/frameworks/config_policy/BUILD.gn b/customization/config_policy/frameworks/config_policy/BUILD.gn
new file mode 100644
index 0000000..443e068
--- /dev/null
+++ b/customization/config_policy/frameworks/config_policy/BUILD.gn
@@ -0,0 +1,30 @@
+# Copyright (c) 2021-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.
+
+import("//base/customization/config_policy/config_policy.gni")
+if (defined(ohos_lite)) {
+ import("//build/lite/config/component/lite_component.gni")
+} else {
+ import("//build/ohos.gni")
+}
+
+config("config_policy_config") {
+ include_dirs = [ "include" ]
+ libs = [ "configpolicy_util.z" ]
+}
+
+ohos_shared_library("configpolicy_util") {
+ all_dependent_configs = [ ":config_policy_config" ]
+ subsystem_name = "customization"
+ part_name = "config_policy"
+}
diff --git a/customization/config_policy/frameworks/config_policy/etc/BUILD.gn b/customization/config_policy/frameworks/config_policy/etc/BUILD.gn
new file mode 100644
index 0000000..73c9d6f
--- /dev/null
+++ b/customization/config_policy/frameworks/config_policy/etc/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+import("//build/ohos.gni")
+
+group("customization_etc") {
+ deps = [ ":customization.para.dac" ]
+}
+
+ohos_prebuilt_etc("customization.para.dac") {
+ source = "customization.para.dac"
+ module_install_dir = "etc/param"
+ subsystem_name = "customization"
+ part_name = "config_policy"
+}
diff --git a/customization/config_policy/frameworks/config_policy/etc/customization.para.dac b/customization/config_policy/frameworks/config_policy/etc/customization.para.dac
new file mode 100644
index 0000000..823c6fb
--- /dev/null
+++ b/customization/config_policy/frameworks/config_policy/etc/customization.para.dac
@@ -0,0 +1,15 @@
+# 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.
+
+const.cust.="root:root:774"
+
diff --git a/customization/config_policy/frameworks/dfx/hisysevent.yaml b/customization/config_policy/frameworks/dfx/hisysevent.yaml
new file mode 100644
index 0000000..200d9e0
--- /dev/null
+++ b/customization/config_policy/frameworks/dfx/hisysevent.yaml
@@ -0,0 +1,27 @@
+# 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.
+
+domain: CUST_CONFIG
+
+# config_policy failed event
+
+CONFIG_POLICY_FAILED:
+ __BASE: {type: FAULT, level: CRITICAL, tag: cfgFail, desc: config policy failed}
+ APINAME: {type: STRING, desc: api name}
+ MSG: {type: STRING, desc: error message}
+
+# config_policy statistic event
+
+CONFIG_POLICY_EVENT:
+ __BASE: {type: STATISTIC, level: MINOR, tag: cfgEvent, desc: get config policy func}
+ APINAME: {type: STRING, desc: api name}
diff --git a/customization/config_policy/frameworks/dfx/hisysevent_adapter/hisysevent_adapter.cpp b/customization/config_policy/frameworks/dfx/hisysevent_adapter/hisysevent_adapter.cpp
new file mode 100644
index 0000000..bd84ab0
--- /dev/null
+++ b/customization/config_policy/frameworks/dfx/hisysevent_adapter/hisysevent_adapter.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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 "hisysevent_adapter.h"
+
+// #include "hisysevent.h"
+#include "hilog/log.h"
+
+namespace OHOS {
+namespace Customization {
+namespace ConfigPolicy {
+using namespace OHOS::HiviewDFX;
+static constexpr HiLogLabel LABEL = { LOG_CORE, 0xD001E00, "ReportConfigPolicyEvent" };
+// const std::string DOMAIN_STR = std::string(HiSysEvent::Domain::CUSTOMIZATION_CONFIG);
+
+void ReportConfigPolicyEvent(ReportType reportType, const std::string &apiName, const std::string &msgInfo)
+{
+ return;
+ // int ret;
+ // if (reportType == ReportType::CONFIG_POLICY_FAILED) {
+ // ret = HiSysEvent::Write(DOMAIN_STR, "CONFIG_POLICY_FAILED", HiSysEvent::EventType::FAULT, "APINAME", apiName,
+ // "MSG", msgInfo);
+ // } else {
+ // ret =
+ // HiSysEvent::Write(DOMAIN_STR, "CONFIG_POLICY_EVENT", HiSysEvent::EventType::STATISTIC, "APINAME", apiName);
+ // }
+
+ // if (ret != 0) {
+ // HiLog::Error(LABEL, "hisysevent write failed! ret %{public}d, apiName %{public}s, errMsg %{public}s", ret,
+ // apiName.c_str(), msgInfo.c_str());
+ // }
+}
+} // namespace ConfigPolicy
+} // namespace Customization
+} // namespace OHOS
diff --git a/customization/config_policy/frameworks/dfx/hisysevent_adapter/hisysevent_adapter.h b/customization/config_policy/frameworks/dfx/hisysevent_adapter/hisysevent_adapter.h
new file mode 100644
index 0000000..ec9a1a2
--- /dev/null
+++ b/customization/config_policy/frameworks/dfx/hisysevent_adapter/hisysevent_adapter.h
@@ -0,0 +1,32 @@
+/*
+ * 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 OHOS_CONFIG_POLICY_DFX_HISYSEVENT_ADAPTER_H
+#define OHOS_CONFIG_POLICY_DFX_HISYSEVENT_ADAPTER_H
+
+#include <string>
+
+namespace OHOS {
+namespace Customization {
+namespace ConfigPolicy {
+enum class ReportType {
+ CONFIG_POLICY_FAILED = 0,
+ CONFIG_POLICY_EVENT,
+};
+void ReportConfigPolicyEvent(ReportType reportType, const std::string &apiName, const std::string &msgInfo);
+} // namespace ConfigPolicy
+} // namespace Customization
+} // namespace OHOS
+#endif // OHOS_CONFIG_POLICY_DFX_HISYSEVENT_ADAPTER_H
diff --git a/customization/config_policy/interfaces/inner_api/include b/customization/config_policy/interfaces/inner_api/include
new file mode 120000
index 0000000..170f6ab
--- /dev/null
+++ b/customization/config_policy/interfaces/inner_api/include
@@ -0,0 +1 @@
+/usr/include/config_policy
\ No newline at end of file
diff --git a/notification/eventhandler/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/notification/eventhandler/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
new file mode 100644
index 0000000..382a0ba
--- /dev/null
+++ b/notification/eventhandler/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
@@ -0,0 +1,7 @@
+**IssueNo**:
+**Description**:
+**Sig**: SIG_BscSoftSrv
+**Feature or Bugfix**:
+**Binary Source**:
+**TDD Result**:
+**XTS Result**:
\ No newline at end of file
diff --git a/notification/eventhandler/LICENSE b/notification/eventhandler/LICENSE
new file mode 100644
index 0000000..4a45986
--- /dev/null
+++ b/notification/eventhandler/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/notification/eventhandler/OAT.xml b/notification/eventhandler/OAT.xml
new file mode 100644
index 0000000..a19c53c
--- /dev/null
+++ b/notification/eventhandler/OAT.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (c) 2021-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.
+
+-->
+<!-- OAT(OSS Audit Tool) configuration guide:
+basedir: Root dir, the basedir + project path is the real source file location.
+licensefile:
+1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
+
+tasklist(only for batch mode):
+1. task: Define oat check thread, each task will start a new thread.
+2. task name: Only an name, no practical effect.
+3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist.
+4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist.
+5. task project: Projects to be checked, the path field define the source root dir of the project.
+
+
+policyList:
+1. policy: All policyitems will be merged to default OAT.xml rules, the name of policy doesn't affect OAT check process.
+2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
+<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
+3. policyitem type:
+ "compatibility" is used to check license compatibility in the specified path;
+ "license" is used to check source license header in the specified path;
+ "copyright" is used to check source copyright header in the specified path;
+ "import" is used to check source dependency in the specified path, such as import ... ,include ...
+ "filetype" is used to check file type in the specified path, supported file types: archive, binary
+ "filename" is used to check whether the specified file exists in the specified path(support projectroot in default OAT.xml), supported file names: LICENSE, README, README.OpenSource
+
+4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
+5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
+6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
+7. policyitem filefilter: Used to bind filefilter which define filter rules.
+8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
+
+Note:If the text contains special characters, please escape them according to the following rules:
+" == &gt;
+& == &gt;
+' == &gt;
+< == &gt;
+> == &gt;
+-->
+<configuration>
+ <oatconfig>
+ <licensefile></licensefile>
+ <policylist>
+ <policy name="projectPolicy" desc="">
+ </policy>
+ </policylist>
+ <filefilterlist>
+ <filefilter name="defaultFilter" desc="Files not to check">
+ <filteritem type="filename" name="*.ha|*.hap|*.rpk" desc="valid and invalid bundle files for tests"/>
+ <filteritem type="filepath" name="figures/.*" desc="Self-developed image"/>
+ </filefilter>
+ </filefilterlist>
+ </oatconfig>
+</configuration>
diff --git a/notification/eventhandler/README_en.md b/notification/eventhandler/README_en.md
new file mode 100644
index 0000000..0b46588
--- /dev/null
+++ b/notification/eventhandler/README_en.md
@@ -0,0 +1,36 @@
+# eventhandler
+
+#### Description
+{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
+
+#### Software Architecture
+Software architecture description
+
+#### Installation
+
+1. xxxx
+2. xxxx
+3. xxxx
+
+#### Instructions
+
+1. xxxx
+2. xxxx
+3. xxxx
+
+#### Contribution
+
+1. Fork the repository
+2. Create Feat_xxx branch
+3. Commit your code
+4. Create Pull Request
+
+
+#### Gitee Feature
+
+1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
+2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
+3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
+4. The most valuable open source project [GVP](https://gitee.com/gvp)
+5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
+6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
diff --git a/notification/eventhandler/README_zh.md b/notification/eventhandler/README_zh.md
new file mode 100644
index 0000000..4fba5bd
--- /dev/null
+++ b/notification/eventhandler/README_zh.md
@@ -0,0 +1,57 @@
+# Eventhandler部件
+
+## 简介
+​ EventHandler提供了OpenHarmony线程间通信的基本能力,可以通过EventRunner创建新线程,将耗时的操作抛到新线程上执行,从而实现在不阻塞原来的线程的基础上合理地处理耗时任务。
+
+​ EventHandler主要包括如下核心类:
+
+| 类 | 功能介绍 |
+| ------------ | ------------------------------------------------------------ |
+| EventRunner | 消息队列的循环分发器,每个线程只有一个EventRunner,主要用于管理消息队列EventQueue,不断地从队列中取出InnerEvent分发至对应的EventHandler处理。 |
+| InnerEvent | 线程之间消息传递的实体封装,EventHandler接收与处理的消息对象。EventHandler待处理的InnerEvent的优先级可在IMMEDIATE、HIGH、LOW、IDLE中选择,并设置合适的delayTime。 |
+| EventHandler | 发送和处理消息的核心类,通过绑定一个EventRunner实现对消息队列进行循环分发的功能。 |
+| EventQueue | 线程消息队列,管理InnerEvent,在初始化EventRunner对象时需要创建一个与之关联的EventQueue。 |
+
+
+### 架构图
+
+**图1** 子系统架构图
+
+![evenhandler](figures/evenhandler.png)
+
+
+
+## 目录
+
+```
+base/notification/eventhandler
+├── interfaces
+│ ├── inner_api # 内部接口存放目录
+│ └── kits # 外部接口存放目录
+│ └── native # C/C++接口
+├── frameworks # 包管理服务框架代码
+│ ├── eventhandler # 内部实现存放目录
+│ ├── napi # js接口实现存放目录
+│ └── native # C/C++接口实现存放目录
+└── test # 测试目录
+```
+
+
+
+## 编译构建
+
+ ./build.sh --product-name xxxx --build-target eventhandler
+
+
+
+## 接口说明
+
+详见[API接口说明文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-emitter.md)。
+
+
+
+## 相关仓
+
+[HiTrace组件](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/README_zh.md)
+
+[HiChecker组件](https://gitee.com/openharmony/hiviewdfx_hichecker/blob/master/README_zh.md)
\ No newline at end of file
diff --git a/notification/eventhandler/bundle.json b/notification/eventhandler/bundle.json
new file mode 100644
index 0000000..904cd7c
--- /dev/null
+++ b/notification/eventhandler/bundle.json
@@ -0,0 +1,77 @@
+{
+ "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": [
+ "//base/notification/eventhandler/frameworks/eventhandler:libeventhandler",
+ "//base/notification/eventhandler/frameworks:eventhandler_native_target",
+ "//base/notification/eventhandler/frameworks:napi_packages"
+ ],
+ "service_group": [
+
+ ]
+ },
+ "inner_kits": [
+ {
+ "header": {
+ "header_base": "//base/notification/eventhandler/interfaces/inner_api",
+ "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/frameworks/eventhandler:libeventhandler"
+ },
+ {
+ "header": {
+ "header_base": "//base/notification/eventhandler/interfaces/kits/native",
+ "header_files": [
+ "native_interface_eventhandler.h"
+ ]
+ },
+ "name": "//base/notification/eventhandler/frameworks/native: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/eventhandler.gni b/notification/eventhandler/eventhandler.gni
new file mode 100644
index 0000000..4a248ed
--- /dev/null
+++ b/notification/eventhandler/eventhandler.gni
@@ -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.
+
+frameworks_path = "//base/notification/eventhandler/frameworks"
+inner_api_path = "//base/notification/eventhandler/interfaces/inner_api"
+kits_path = "//base/notification/eventhandler/interfaces/kits"
+
+if (!defined(global_parts_info) ||
+ defined(global_parts_info.hiviewdfx_hichecker_native)) {
+ has_hichecker_native_part = true
+} else {
+ has_hichecker_native_part = false
+}
diff --git a/notification/eventhandler/frameworks/BUILD.gn b/notification/eventhandler/frameworks/BUILD.gn
new file mode 100644
index 0000000..6e381e5
--- /dev/null
+++ b/notification/eventhandler/frameworks/BUILD.gn
@@ -0,0 +1,23 @@
+# Copyright (c) 2021-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("napi_packages") {
+ deps = []
+ if (support_jsapi) {
+ deps += [ "napi:emitter" ]
+ }
+}
+
+group("eventhandler_native_target") {
+ deps = [ "native:eventhandler_native" ]
+}
diff --git a/notification/eventhandler/frameworks/eventhandler/BUILD.gn b/notification/eventhandler/frameworks/eventhandler/BUILD.gn
new file mode 100644
index 0000000..41098b2
--- /dev/null
+++ b/notification/eventhandler/frameworks/eventhandler/BUILD.gn
@@ -0,0 +1,27 @@
+# Copyright (c) 2021-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.
+
+import("//build/ohos.gni")
+import("../../eventhandler.gni")
+import("inner_api_sources.gni")
+
+config("libeventhandler_config") {
+ include_dirs = [ "include" ]
+ libs = [ "eventhandler.z" ]
+}
+
+ohos_shared_library("libeventhandler") {
+ all_dependent_configs = [ ":libeventhandler_config" ]
+ subsystem_name = "notification"
+ part_name = "eventhandler"
+}
diff --git a/notification/eventhandler/frameworks/eventhandler/include/epoll_io_waiter.h b/notification/eventhandler/frameworks/eventhandler/include/epoll_io_waiter.h
new file mode 100644
index 0000000..73150db
--- /dev/null
+++ b/notification/eventhandler/frameworks/eventhandler/include/epoll_io_waiter.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2021-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 BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_EPOLL_IO_WAITER_H
+#define BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_EPOLL_IO_WAITER_H
+
+#include <atomic>
+#include <mutex>
+
+#include "io_waiter.h"
+#include "nocopyable.h"
+
+namespace OHOS {
+namespace AppExecFwk {
+// Use epoll to listen file descriptor.
+class EpollIoWaiter final : public IoWaiter {
+public:
+ EpollIoWaiter() = default;
+ ~EpollIoWaiter() final;
+ DISALLOW_COPY_AND_MOVE(EpollIoWaiter);
+
+ /**
+ * Initialize epoll.
+ *
+ * @return True if succeeded.
+ */
+ bool Init();
+
+ bool WaitFor(std::unique_lock<std::mutex> &lock, int64_t nanoseconds) final;
+
+ void NotifyOne() final;
+ void NotifyAll() final;
+
+ bool SupportListeningFileDescriptor() const final;
+
+ bool AddFileDescriptor(int32_t fileDescriptor, uint32_t events) final;
+ void RemoveFileDescriptor(int32_t fileDescriptor) final;
+
+ void SetFileDescriptorEventCallback(const FileDescriptorEventCallback &callback) final;
+
+private:
+ void DrainAwakenPipe() const;
+
+ // File descriptor for epoll.
+ int32_t epollFd_{-1};
+ // File descriptor used to wake up epoll.
+ int32_t awakenFd_{-1};
+
+ FileDescriptorEventCallback callback_;
+ std::atomic<uint32_t> waitingCount_{0};
+};
+} // namespace AppExecFwk
+} // namespace OHOS
+
+#endif // #ifndef BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_EPOLL_IO_WAITER_H
diff --git a/notification/eventhandler/frameworks/eventhandler/include/event_handler_utils.h b/notification/eventhandler/frameworks/eventhandler/include/event_handler_utils.h
new file mode 100644
index 0000000..37e862f
--- /dev/null
+++ b/notification/eventhandler/frameworks/eventhandler/include/event_handler_utils.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2021-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 BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_EVENT_HANDLER_UTILS_H
+#define BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_EVENT_HANDLER_UTILS_H
+
+#include <cerrno>
+#include <chrono>
+#include <cstring>
+#include <string>
+
+#include "hilog/log.h"
+// #include "hitrace/trace.h"
+#include "inner_event.h"
+
+#define DEFINE_HILOG_LABEL(name) \
+static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, LOG_DOMAIN, name}
+
+#define HILOGE(...) OHOS::HiviewDFX::HiLog::Error(LOG_LABEL, ##__VA_ARGS__)
+#define HILOGW(...) OHOS::HiviewDFX::HiLog::Warn(LOG_LABEL, ##__VA_ARGS__)
+#define HILOGI(...) OHOS::HiviewDFX::HiLog::Info(LOG_LABEL, ##__VA_ARGS__)
+#define HILOGD(...) OHOS::HiviewDFX::HiLog::Debug(LOG_LABEL, ##__VA_ARGS__)
+
+namespace OHOS {
+namespace AppExecFwk {
+inline const int64_t NANOSECONDS_PER_ONE_MILLISECOND = 1000000;
+inline const int64_t NANOSECONDS_PER_ONE_SECOND = 1000000000;
+inline const int32_t INFINITE_TIMEOUT = -1;
+inline const uint8_t MAX_ERRORMSG_LEN = 128;
+
+// Help to convert time point into delay time from now.
+static inline int64_t TimePointToTimeOut(const InnerEvent::TimePoint &when)
+{
+ InnerEvent::TimePoint now = InnerEvent::Clock::now();
+ if (when <= now) {
+ return 0;
+ }
+
+ auto duration = when - now;
+ return std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count();
+}
+
+static inline int32_t NanosecondsToTimeout(int64_t nanoseconds)
+{
+ if (nanoseconds < 0) {
+ return INFINITE_TIMEOUT;
+ }
+
+ int64_t milliseconds = nanoseconds / NANOSECONDS_PER_ONE_MILLISECOND;
+ if ((nanoseconds % NANOSECONDS_PER_ONE_MILLISECOND) > 0) {
+ milliseconds += 1;
+ }
+
+ return (milliseconds > INT32_MAX) ? INT32_MAX : static_cast<int32_t>(milliseconds);
+}
+
+// using HiTraceChain = OHOS::HiviewDFX::HiTraceChain;
+
+static inline bool AllowHiTraceOutPut(const std::shared_ptr<HiTraceId>& traceId, bool isSyncEvent)
+{
+ // 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<HiTraceId>& 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)
+{
+ size = size > MAX_ERRORMSG_LEN ? MAX_ERRORMSG_LEN : size;
+ strerror_r(errno, errmsg, size);
+}
+} // namespace AppExecFwk
+} // namespace OHOS
+
+#endif // #ifndef BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_EVENT_HANDLER_UTILS_H
diff --git a/notification/eventhandler/frameworks/eventhandler/include/event_inner_runner.h b/notification/eventhandler/frameworks/eventhandler/include/event_inner_runner.h
new file mode 100644
index 0000000..1e212a9
--- /dev/null
+++ b/notification/eventhandler/frameworks/eventhandler/include/event_inner_runner.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2021-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 BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_EVENT_INNER_RUNNER_H
+#define BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_EVENT_INNER_RUNNER_H
+
+#include "event_handler_utils.h"
+#include "event_queue.h"
+#include "event_runner.h"
+#include "nocopyable.h"
+#include "thread_local_data.h"
+
+namespace OHOS {
+namespace AppExecFwk {
+class EventInnerRunner {
+public:
+ explicit EventInnerRunner(const std::shared_ptr<EventRunner> &runner);
+ virtual ~EventInnerRunner() = default;
+ DISALLOW_COPY_AND_MOVE(EventInnerRunner);
+
+ static std::shared_ptr<EventRunner> GetCurrentEventRunner();
+
+ virtual void Run() = 0;
+ virtual void Stop() = 0;
+
+ const std::shared_ptr<EventQueue> &GetEventQueue() const
+ {
+ return queue_;
+ }
+
+ void SetLogger(const std::shared_ptr<Logger> &logger)
+ {
+ logger_ = logger;
+ }
+
+ const std::string &GetThreadName()
+ {
+ return threadName_;
+ }
+
+ const std::thread::id &GetThreadId()
+ {
+ return threadId_;
+ }
+
+protected:
+ std::shared_ptr<EventQueue> queue_;
+ std::weak_ptr<EventRunner> owner_;
+ std::shared_ptr<Logger> logger_;
+ static ThreadLocalData<std::weak_ptr<EventRunner>> currentEventRunner;
+ std::string threadName_;
+ std::thread::id threadId_;
+};
+} // namespace AppExecFwk
+} // namespace OHOS
+
+#endif // #ifndef BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_EVENT_INNER_RUNNER_H
diff --git a/notification/eventhandler/frameworks/eventhandler/include/io_waiter.h b/notification/eventhandler/frameworks/eventhandler/include/io_waiter.h
new file mode 100644
index 0000000..f356772
--- /dev/null
+++ b/notification/eventhandler/frameworks/eventhandler/include/io_waiter.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2021-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 BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_IO_WAITER_H
+#define BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_IO_WAITER_H
+
+#include <cerrno>
+#include <cstdint>
+#include <functional>
+#include <mutex>
+
+#include "nocopyable.h"
+
+namespace OHOS {
+namespace AppExecFwk {
+// Interface of IO waiter
+class IoWaiter {
+public:
+ using FileDescriptorEventCallback = std::function<void(int32_t, uint32_t)>;
+
+ IoWaiter() = default;
+ virtual ~IoWaiter() = default;
+ DISALLOW_COPY_AND_MOVE(IoWaiter);
+
+ /**
+ * Wait until IO event coming or timed out.
+ *
+ * @param lock An unique lock which must be locked by the current thread.
+ * @param nanoseconds Nanoseconds for time out, negative value indicate waiting forever.
+ * @return True if succeeded.
+ */
+ virtual bool WaitFor(std::unique_lock<std::mutex> &lock, int64_t nanoseconds) = 0;
+
+ /**
+ * Unblocks one of the waiting threads.
+ */
+ virtual void NotifyOne() = 0;
+
+ /**
+ * Unblocks all of the waiting threads.
+ */
+ virtual void NotifyAll() = 0;
+
+ /**
+ * Check whether this waiter support listening file descriptor.
+ *
+ * @return True if supported.
+ */
+ virtual bool SupportListeningFileDescriptor() const = 0;
+
+ /**
+ * Add file descriptor.
+ *
+ * @param fileDescriptor File descriptor which need to listen.
+ * @param events Events from file descriptor, such as input, output.
+ * @return True if succeeded.
+ */
+ virtual bool AddFileDescriptor(int32_t fileDescriptor, uint32_t events) = 0;
+
+ /**
+ * Remove file descriptor.
+ *
+ * @param fileDescriptor File descriptor which need to remove.
+ */
+ virtual void RemoveFileDescriptor(int32_t fileDescriptor) = 0;
+
+ /**
+ * Set callback to handle events from file descriptors, such as readable, writable and so on.
+ *
+ * @param callback Callback function to handle events from file descriptors.
+ */
+ virtual void SetFileDescriptorEventCallback(const FileDescriptorEventCallback &callback) = 0;
+};
+} // namespace AppExecFwk
+} // namespace OHOS
+
+#endif // #ifndef BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_IO_WAITER_H
diff --git a/notification/eventhandler/frameworks/eventhandler/include/none_io_waiter.h b/notification/eventhandler/frameworks/eventhandler/include/none_io_waiter.h
new file mode 100644
index 0000000..6458778
--- /dev/null
+++ b/notification/eventhandler/frameworks/eventhandler/include/none_io_waiter.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2021-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 BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_NONE_IO_WAITER_H
+#define BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_NONE_IO_WAITER_H
+
+#include <condition_variable>
+#include <mutex>
+
+#include "io_waiter.h"
+#include "nocopyable.h"
+
+namespace OHOS {
+namespace AppExecFwk {
+// Io waiter which does not support listening file descriptor.
+class NoneIoWaiter final : public IoWaiter {
+public:
+ NoneIoWaiter() = default;
+ ~NoneIoWaiter() final;
+ DISALLOW_COPY_AND_MOVE(NoneIoWaiter);
+
+ bool WaitFor(std::unique_lock<std::mutex> &lock, int64_t nanoseconds) final;
+
+ void NotifyOne() final;
+ void NotifyAll() final;
+
+ bool SupportListeningFileDescriptor() const final;
+
+ bool AddFileDescriptor(int32_t fileDescriptor, uint32_t events) final;
+ void RemoveFileDescriptor(int32_t fileDescriptor) final;
+
+ void SetFileDescriptorEventCallback(const FileDescriptorEventCallback &callback) final;
+
+private:
+ std::condition_variable condition_;
+ uint32_t waitingCount_ {0};
+ bool pred_ {false};
+};
+} // namespace AppExecFwk
+} // namespace OHOS
+
+#endif // #ifndef BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_NONE_IO_WAITER_H
diff --git a/notification/eventhandler/frameworks/eventhandler/include/thread_local_data.h b/notification/eventhandler/frameworks/eventhandler/include/thread_local_data.h
new file mode 100644
index 0000000..6921a55
--- /dev/null
+++ b/notification/eventhandler/frameworks/eventhandler/include/thread_local_data.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2021-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 BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_THREAD_LOCAL_DATA_H
+#define BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_THREAD_LOCAL_DATA_H
+
+#include <mutex>
+#include <thread>
+#include <unordered_map>
+
+#include "nocopyable.h"
+
+namespace OHOS {
+namespace AppExecFwk {
+/*
+ * Tool class, used to save thread local data.
+ */
+template<typename T>
+class ThreadLocalData {
+public:
+ ThreadLocalData() = default;
+ ~ThreadLocalData() = default;
+ DISALLOW_COPY_AND_MOVE(ThreadLocalData);
+
+ /*
+ * Override type conversion method.
+ */
+ inline operator T() const
+ {
+ return Current();
+ }
+
+ /*
+ * Override operator equal to save data.
+ */
+ inline const ThreadLocalData<T> &operator=(const T &data)
+ {
+ Save(data);
+ return *this;
+ }
+
+ /*
+ * Override operator equal to nullptr, which can used to discard the saved data.
+ */
+ inline const ThreadLocalData<T> &operator=(std::nullptr_t)
+ {
+ Discard();
+ return *this;
+ }
+
+private:
+ inline T Current() const
+ {
+ std::lock_guard<std::mutex> lock(mapLock_);
+ auto it = dataMap_.find(std::this_thread::get_id());
+ if (it == dataMap_.end()) {
+ return T();
+ } else {
+ return it->second;
+ }
+ }
+
+ inline void Save(const T &data)
+ {
+ std::lock_guard<std::mutex> lock(mapLock_);
+ dataMap_[std::this_thread::get_id()] = data;
+ }
+
+ inline void Discard()
+ {
+ std::lock_guard<std::mutex> lock(mapLock_);
+ (void)dataMap_.erase(std::this_thread::get_id());
+ }
+
+ mutable std::mutex mapLock_;
+ std::unordered_map<std::thread::id, T> dataMap_;
+};
+} // namespace AppExecFwk
+} // namespace OHOS
+
+#endif // #ifndef BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_THREAD_LOCAL_DATA_H
diff --git a/notification/eventhandler/frameworks/eventhandler/inner_api_sources.gni b/notification/eventhandler/frameworks/eventhandler/inner_api_sources.gni
new file mode 100644
index 0000000..dab3ade
--- /dev/null
+++ b/notification/eventhandler/frameworks/eventhandler/inner_api_sources.gni
@@ -0,0 +1,26 @@
+# Copyright (c) 2021-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.
+import("../../eventhandler.gni")
+
+inner_api_sources = [
+ "${frameworks_path}/eventhandler/src/epoll_io_waiter.cpp",
+ "${frameworks_path}/eventhandler/src/event_handler.cpp",
+ "${frameworks_path}/eventhandler/src/event_queue.cpp",
+ "${frameworks_path}/eventhandler/src/event_runner.cpp",
+ "${frameworks_path}/eventhandler/src/file_descriptor_listener.cpp",
+ "${frameworks_path}/eventhandler/src/inner_event.cpp",
+ "${frameworks_path}/eventhandler/src/native_implement_eventhandler.cpp",
+ "${frameworks_path}/eventhandler/src/none_io_waiter.cpp",
+]
+
+event_handler_log_domain_defines = [ "LOG_DOMAIN=0xD001200" ]
diff --git a/notification/eventhandler/frameworks/napi/BUILD.gn b/notification/eventhandler/frameworks/napi/BUILD.gn
new file mode 100644
index 0000000..0861a03
--- /dev/null
+++ b/notification/eventhandler/frameworks/napi/BUILD.gn
@@ -0,0 +1,27 @@
+# Copyright (c) 2021-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.
+
+import("//build/ohos.gni")
+import("//build/ohos/ace/ace.gni")
+import("../../eventhandler.gni")
+
+config("emitter_config") {
+ include_dirs = [ "include" ]
+ libs = [ "emitter" ]
+}
+
+ohos_shared_library("emitter") {
+ all_dependent_configs = [ ":emitter_config" ]
+ subsystem_name = "notification"
+ part_name = "eventhandler"
+}
diff --git a/notification/eventhandler/frameworks/napi/include/events_emitter.h b/notification/eventhandler/frameworks/napi/include/events_emitter.h
new file mode 100644
index 0000000..765a4db
--- /dev/null
+++ b/notification/eventhandler/frameworks/napi/include/events_emitter.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2021-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 BASE_EVENTHANDLER_FRAMEWORKS_NAPI_INCLUDE_JS_EMITTER_H
+#define BASE_EVENTHANDLER_FRAMEWORKS_NAPI_INCLUDE_JS_EMITTER_H
+
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "event_handler.h"
+#include "event_runner.h"
+#include "event_queue.h"
+#include "inner_event.h"
+
+#include "napi/native_api.h"
+#include "napi/native_node_api.h"
+
+namespace OHOS {
+namespace AppExecFwk {
+using Priority = EventQueue::Priority;
+static const int32_t ARGC_NUM = 2;
+static const int32_t NAPI_VALUE_STRING_LEN = 10240;
+class EventHandlerInstance : public EventHandler {
+public:
+ EventHandlerInstance(const std::shared_ptr<EventRunner>& runner);
+ static std::shared_ptr<EventHandlerInstance> GetInstance();
+ ~EventHandlerInstance();
+ void ProcessEvent(const InnerEvent::Pointer& event) override;
+};
+
+enum class DataType: uint32_t {
+ BOOL = 0,
+ INT,
+ STRING,
+};
+
+struct Val {
+ DataType type;
+
+ union {
+ bool bValue;
+ int32_t nValue;
+ char cValue[NAPI_VALUE_STRING_LEN] = {0};
+ } value;
+};
+
+struct AsyncCallbackInfo {
+ napi_env env;
+ bool once = false;
+ bool isDeleted = false;
+ napi_ref callback = 0;
+};
+
+using EventData = std::map<std::string, Val>;
+struct EventDataWorker {
+ EventData data;
+ AsyncCallbackInfo* callbackInfo;
+};
+
+napi_value EmitterInit(napi_env env, napi_value exports);
+napi_value JS_On(napi_env env, napi_callback_info cbinfo);
+napi_value JS_Off(napi_env env, napi_callback_info cbinfo);
+napi_value JS_Once(napi_env env, napi_callback_info cbinfo);
+napi_value JS_Emit(napi_env env, napi_callback_info cbinfo);
+} // namespace AppExecFwk
+} // namespace OHOS
+
+#endif // BASE_EVENTHANDLER_FRAMEWORKS_NAPI_INCLUDE_JS_EMITTER_H
\ No newline at end of file
diff --git a/notification/eventhandler/frameworks/native/BUILD.gn b/notification/eventhandler/frameworks/native/BUILD.gn
new file mode 100644
index 0000000..e77c7c6
--- /dev/null
+++ b/notification/eventhandler/frameworks/native/BUILD.gn
@@ -0,0 +1,26 @@
+# Copyright (c) 2021-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.
+
+import("//build/ohos.gni")
+import("../../eventhandler.gni")
+
+config("eventhandler_native_config") {
+ include_dirs = [ "include" ]
+ libs = [ "eventhandler_native.z" ]
+}
+
+ohos_shared_library("eventhandler_native") {
+ all_dependent_configs = [ ":eventhandler_native_config" ]
+ subsystem_name = "notification"
+ part_name = "eventhandler"
+}
diff --git a/notification/eventhandler/interfaces/inner_api b/notification/eventhandler/interfaces/inner_api
new file mode 120000
index 0000000..6a78252
--- /dev/null
+++ b/notification/eventhandler/interfaces/inner_api
@@ -0,0 +1 @@
+/usr/include/eventhandler/
\ No newline at end of file
diff --git a/openeuler/vendor/openeuler/openeuler/config.json b/openeuler/vendor/openeuler/openeuler/config.json
index 2dfbb49..c15bfad 100644
--- a/openeuler/vendor/openeuler/openeuler/config.json
+++ b/openeuler/vendor/openeuler/openeuler/config.json
@@ -51,6 +51,15 @@
}
]
},
+ {
+ "subsystem": "customization",
+ "components": [
+ {
+ "component": "config_policy",
+ "features": []
+ }
+ ]
+ },
{
"subsystem": "startup",
"components": [
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chrisshangguan/distributed-build.git
git@gitee.com:chrisshangguan/distributed-build.git
chrisshangguan
distributed-build
distributed-build
master

搜索帮助